一个通过Oracle8i存储过程,返回记录集的程序包(存储过程)
2007-05-13 12:30:28 来源:WEB开发网核心提示: Select Count(*) Into IsExists from all_tables Where Trim(Table_Name)='TEMPAGTBALANCE';IF IsExists=0 Then strSQL:='CREATE GLOBAL TEMPO
Select Count(*) Into IsExists from all_tables Where Trim(Table_Name)='TEMPAGTBALANCE';
IF IsExists=0 Then
strSQL:='CREATE GLOBAL TEMPORARY TABLE SMS_PAY.TEMPAgtBalance
(FSTAGTID VARCHAR2(13) ,SECAgtID VARCHAR2(13),ParentID VARCHAR2(13),
AgtBalance NUMBER(10,2),AgtProfit NUMBER(10,2),AreaCode VARCHAR2(10),
AreaName VARCHAR2(30),AgtCount NUMBER(10)) on commit preserve rows';
--把临时表的创建选项由on commit delete rows改为on commit preserve rows;
--否则在调用的时候,回出现ORA-08103: object no longer exists
--DBMS_OUTPUT.PUT_LINE(strSQL);
Execute Immediate strSQL;
Else
execute immediate 'Truncate table Sms_pay.TEMPAgtBalance';
End IF;
--检查临时表是否已经存在,如果不存在,则创建,否则插入数据 end
Loop
Fetch FstCursor into pFSTAGTID,pSECAgtID, pAgtBalance,pAgtProfit,pAreaCode, pAreaName, pAgtCount ;
Exit when FstCursor%NOTFOUND;
--1:写1级代理商查询信息
strSQL:='Insert into TEMPAgtBalance(FSTAGTID,SECAgtID, ParentID,AgtBalance,AgtProfit,AreaCode, AreaName, AgtCount)
Values(''' || pFSTAGTID || ''',null,null,' || pAgtBalance || ',' || pAgtProfit || ',''' || pAreaCode || ''','''
|| pAreaName || ''',' || pAgtCount || ')';
Execute Immediate strSQL;
--2:写2级代理商查询信息
更多精彩
赞助商链接