1、oracle存储过程代码实例一1、用来插入大量测试数据的存储过程CREATEORREPLACEPROCEDUREINSERTAMOUNTTEST(ST_NUM IN NUMBER,ED_NUM IN NUMBER)ISBEGINdeclare i number;beginFORiINST_NUM..ED_NUMLOOPINSERTINTOtbvalues(i,i,'3','3','3',100,'0');ENDLOOP;end;END;运行:sql>execu
3、sertintotdvalues(varAppTypeId,varFlowId,DateLength)returning1intoReturnValue; --返回值commit;exceptionwhenothersthenrollback;end;存储过程的执行sql>variabletestvalue number;sql>executespaddflowdate('v','v',2,:testvalue);sql>print就可以看到执行结果 3、用包实现存储过程返回游标:create or re
4、place package test_p as type outList is ref cursor; PROCEDURE getinfor(taxpayerList out outList); end test_p; / create or replace package body test_p as PROCEDURE getinfor(taxpayerListout outList) is begin OPEN taxpayerList FOR select * from
5、 tdwheretag='0'; end getinfor; end test_p; / 运行: set serverout on; --将输出工具打开 variable x refcursor; executetest_p.getinfor(:x);exec test_p.getinfor(:x); print x; droppackagetest_p;认识存储过程和函数存储过程和函数也是一种PL/SQL块,是存入数据库的PL/SQL块。但存储过程和函数