10 PL/SQL编程基础A
2012-08-14 10:31
274 查看
1 注释
单行--
多行/*...*/
2 命名规则
变量:v_name
常量:c_name
游标:name_cursor
异常:e_name
Block(pl/sql编程基本单元)(过程、函数、触发器、包)
set serveroutput on;/***控制台显示开启***/
declare
v_name varchar2(20);
begin
select name into v_name from test where id=&id;
dbms_output.put_line(v_name);
exception
when no_data_found then
dbms_output.put_line('对不起 !用户不存在');
end;
create or replace procedure my_pro3(v_id number) is
v_tax_rate number(3,2):=0.03;/***赋初值***/
v_sal test.sal%type;/***%type***/
v_name varchar2(20);
v_tax number;
begin
select name,sal into v_name,v_sal from test where id=v_id;/***=判断是否相等***/
v_tax:=v_sal*v_tax_rate;
dbms_output.put_line('雇员' || v_name || '的工资是' ||v_sal ||',个人所得税是' ||v_tax);
end;
create or replace procedure my_pro4(v_id number) is
type my_record is record(
v_name test.name%type,
v_sal test.sal%type
);
v_record my_record;
begin
select name,sal into v_record from test where id=v_id;
dbms_output.put_line('雇员'|| v_record.v_name || ',工资' || v_record.v_sal);
end;
单行--
多行/*...*/
2 命名规则
变量:v_name
常量:c_name
游标:name_cursor
异常:e_name
Block(pl/sql编程基本单元)(过程、函数、触发器、包)
set serveroutput on;/***控制台显示开启***/
declare
v_name varchar2(20);
begin
select name into v_name from test where id=&id;
dbms_output.put_line(v_name);
exception
when no_data_found then
dbms_output.put_line('对不起 !用户不存在');
end;
create or replace procedure my_pro3(v_id number) is
v_tax_rate number(3,2):=0.03;/***赋初值***/
v_sal test.sal%type;/***%type***/
v_name varchar2(20);
v_tax number;
begin
select name,sal into v_name,v_sal from test where id=v_id;/***=判断是否相等***/
v_tax:=v_sal*v_tax_rate;
dbms_output.put_line('雇员' || v_name || '的工资是' ||v_sal ||',个人所得税是' ||v_tax);
end;
create or replace procedure my_pro4(v_id number) is
type my_record is record(
v_name test.name%type,
v_sal test.sal%type
);
v_record my_record;
begin
select name,sal into v_record from test where id=v_id;
dbms_output.put_line('雇员'|| v_record.v_name || ',工资' || v_record.v_sal);
end;
相关文章推荐
- Oracle(PL/SQL编程基础(PL/SQL程序块与PL/SQL语句)、异常、游标、数据类型)
- Oracle PL/SQL 编程基础 实例
- PL/SQL编程基础
- Oracle PL/SQL DBA 编程实践基础
- PL/SQL 基础编程
- PL/SQL编程基础
- PL/sql编程基础
- PL_SQL基础编程
- PL/SQL编程基础
- Oracle之PL/SQL编程基础
- Oracle PL/SQL 编程基础
- 用10!来回顾 PL/SQL语言基础 && 标准异常名
- 基础:Oracle9i PL/SQL编程的经验小结
- pl/sql编程基础
- Oracle学习笔记——PL/SQL编程基础
- PL/SQL编程基础
- oracle pl/sql 几道基础的编程题
- Oracle的pl/sql编程基础
- 原创:oracle PL/SQL编程基础 上(十一)
- Oracle PL/SQL编程基础