先创建存储过程,SCOTT为用户。 create or replace procedure sele_emp(v_id in scott.emp.empno%type, v_sal out scott.emp.sal%type) as begin select sal into v_sal from scott.emp where empno = v_id; end;调用存储过程: declare v1 scott.emp.sal%type; begin sele_emp(7788,v1); dbms_output.put_line('所得税金额:'||v1); end;create or replace procedure last1_emp(id number, on_flag out number) is begin select comm into on_flag from scott.emp where empno = id; end;declare v1 scott.emp.comm%type; begin last1_emp(7566, v1); dbms_output.put_line('工资级别:' || v1); end; /
先创建存储过程,SCOTT为用户。 create or replace procedure sele_emp(v_id in scott.emp.empno%type, v_sal out scott.emp.sal%type) as begin select sal into v_sal from scott.emp where empno = v_id; end;调用存储过程: declare v1 scott.emp.sal%type; begin sele_emp(7788,v1); dbms_output.put_line('所得税金额:'||v1); end;create or replace procedure last1_emp(id number, on_flag out number) is begin select comm into on_flag from scott.emp where empno = id; end;declare v1 scott.emp.comm%type; begin last1_emp(7566, v1); dbms_output.put_line('工资级别:' || v1); end; /+1 就是这样的
create or replace procedure sele_emp ( v_id in emo.empno%type; --是英文状态下的 逗号 , v_sal out emo.sal%type; --这个后面没有分号 )
到第一个end结束为存储过程。
declare到end为对存储过程的测试过程。。
建议先在sql窗口创建存储过程。
再在测试窗口测试存储过程。
create or replace procedure sele_emp(v_id in scott.emp.empno%type,
v_sal out scott.emp.sal%type) as
begin
select sal into v_sal from scott.emp where empno = v_id;
end;调用存储过程:
declare
v1 scott.emp.sal%type;
begin
sele_emp(7788,v1);
dbms_output.put_line('所得税金额:'||v1);
end;create or replace procedure last1_emp(id number, on_flag out number) is
begin
select comm into on_flag from scott.emp where empno = id;
end;declare
v1 scott.emp.comm%type;
begin
last1_emp(7566, v1);
dbms_output.put_line('工资级别:' || v1);
end;
/
create or replace procedure sele_emp(v_id in scott.emp.empno%type,
v_sal out scott.emp.sal%type) as
begin
select sal into v_sal from scott.emp where empno = v_id;
end;调用存储过程:
declare
v1 scott.emp.sal%type;
begin
sele_emp(7788,v1);
dbms_output.put_line('所得税金额:'||v1);
end;create or replace procedure last1_emp(id number, on_flag out number) is
begin
select comm into on_flag from scott.emp where empno = id;
end;declare
v1 scott.emp.comm%type;
begin
last1_emp(7566, v1);
dbms_output.put_line('工资级别:' || v1);
end;
/+1 就是这样的
(
v_id in emo.empno%type; --是英文状态下的 逗号 ,
v_sal out emo.sal%type; --这个后面没有分号
)