1.无返回值的
create or replace procedure testb(pid in varchar2,pname in varchar2,ppwd in varchar2,page in number)
as
--变量定义
begin
insert into worker(id,name,pwd,age) values (pid,pname,ppwd,page);
end testa;
create or replace procedure testa(pid in varchar2)
as
begin
delete from worker w where w.id=pid;
end testa;
//测试脚本:
declare
i number;
begin
testb('8','daming','daming',29);
end;
//执行存储过程:
SET SERVEROUTPUT ON;
execute testb('7','daming','daming',29);
2(1).有返回值的
create or replace procedure testc(page1 in number,page2 in number,param out number)
as
--变量定义
begin
select count(w.name)) into param from worker w where w.age between page1 and page2;
end testc;
//测试脚本:
declare
i number;
begin
testc(22,27,i);
dbms_output.put_line(i);
end;
2(2).有返回值的
create or replace procedure testd(page1 in number,page2 in number,param1 out number,param2 out number)
as
--变量定义
begin
select count(w.name),sum(w.age) into param1,param2 from worker w where w.age between page1 and page2;
end testd;
//测试脚本:
declare
param1 number;
param2 number;
begin
testd(22,27,param1,param2);
dbms_output.put_line(param1);
dbms_output.put_line(param2);
end;