创建:
create or replace procedure insert_tbuser
(
username nvarchar2,usersex nvarchar2,userage number
)
as
begin
insert into tbuser values(username,usersex,userage);
end insert_tbuser;
调用:
begin
insert_tbuser('linhuide','nan',20);
commit;
end; 创建输出结果集的存储过程:
create or replace procedure up_test(o out sys_refcursor) is
begin
open o for select * from tbuser;
end; --声明包头
CREATE
OR
REPLACE
PACKAGE PACK_TEST
AS
--这个是游标
TYPE TESTCUR
IS
REF
CURSOR
;
--这个是过程
PROCEDURE
sp_test1(DWMC
in
VARCHAR2, LX
in
VARCHAR2,
P_CUR
OUT
TESTCUR);
END
PACK_TEST;
--声明包体
CREATE
OR
REPLACE
PACKAGE BODY PACK_TEST
AS
PROCEDURE
sp_test1(DWMC
in
VARCHAR2, LX
in
VARCHAR2,
P_CUR
OUT
TESTCUR)
is
strsql varchar2(1000);
begin
strsql:=
'select * from test_table where dwmc=:dwmc and lx=:lx'
;
open
p_cur
for
strsql using dwdc,lx;
--上一句的:及这一句为绑定变量
end
sp_test1;
end
PACK_TEST;