提示:在Oracle8i中,如果需要通過存儲過程返回結果集, 需要使用游標!
CREATE OR REPLACE PACKAGE BODY "SMS_PAY"."SMSMAINT"
IS
--功能描述:查詢代理銀行交易流水信息 writer: wang haibo 2004-08-24
PROCEDURE GetAgtBankFlow(AreaCode in varchar2,KeyWord in varchar2,startTradeDate in varchar2,endTradeDate in varchar2,Re_CURSOR OUT T_CURSOR,ret out number)
is
IsExists number;
strSQL VARCHAR2(2048);
Begin
--檢查臨時表是否已經存在,如果不存在,則創建,否則插入數據 start
Select Count(*) Into IsExists from all_tables Where Table_Name='TEMPAGTBANKFLOW';
IF IsExists=0 Then
strSQL:='CREATE GLOBAL TEMPORARY TABLE SMS_PAY.TEMPAgtBankFlow
(AGTID VARCHAR2(13) ,BANK_GLIDE Number(12),TradeType VARCHAR2(20),Trade_Money Number(14,2),
TRADEDATE VARCHAR2(10),TRADETIME VARCHAR2(8),BankNAME VARCHAR2(30),
AreaCode Varchar2(30), AreaName VARCHAR2(30),State VARCHAR2(30),CheckFlag Number(1),
StatusFlag Number(1),SuccFlag Number(1)) on commit preserve rows';
--把臨時表的創建選項由on commit delete rows改為on commit preserve rows;
--否則在調用的時候,回出現ORA-08103: object no longer exists
Execute Immediate strSQL;
Else
Execute immediate 'Truncate table Sms_pay.TEMPAGTBANKFLOW';
End IF;
--檢查臨時表是否已經存在,如果不存在,則創建,否則插入數據 end
---功能:把滿足條件的一級代理商轉帳信息導入數據庫 Start
/*strSQL:='Insert Into TEMPAgtBankFlow
Select A.Agent_Mobile,A.Bank_Glide,
Decode(A.OPTCode,''100'',''交款交易'',''101'',''交款沖正'',''900'',''抹帳交易'',''類型不明'') as TradeType,A.Trade_Money,
TO_Char(To_Date(A.Trade_Date,''YYYYMMDD''),''YYYY-MM-DD'') as TradeDate,
TO_Char(To_Date(A.Trade_Time,''hh24miss''),''hh24:mi:ss'') as TradeTime,B.BankName,C.AreaCode,C.AreaName,
(Case When CheckFlag=-1 Then ''/Images/state_rollback.gif'' When SuccFlag=-1 Then ''/Images/state_cancel.gif'' When StatusFlag=-1 Then ''/Images/state_unnormal.gif'' Else ''/Images/state_normal.gif'' End) as State
From Bank_Stream_Account A,BankInfoConfig B,AreaConfig C,FstAgtAccount D
Where A.Bank_ID=B.BankCode And Trim(A.Agent_Mobile)=D.AgtID And C.CityCode=D.CityCode ';
IF AreaCode!='0' Then --條件1: 選擇所有地區的信息
strSQL:=strSQL || ' And Trim(C.AreaCode)=''' || AreaCode || ''' ';
End IF;
IF TradeDate!=' ' Then --條件2: 選擇所有地區的信息,選擇所有交易日期的信息
strSQL:=strSQL || ' And TO_Char(To_Date(A.Trade_Date,''YYYYMMDD''),''YYYY-MM-DD'')=''' || TradeDate || ''' ';
End If;
IF KeyWord!=' ' Then --條件3: 選擇所有地區的信息,選擇所有交易日期的信息,選擇和查詢關鍵字匹配的信息
strSQL:=strSQL || ' And (D.AgtID Like''%' || KeyWord || '%'' Or TO_Char(A.BANK_GLIDE) Like ''%' || KeyWord || '%'' Or B.BankName Like ''%' || KeyWord ||'%'') ';
End If;
Execute Immediate strSQL;
---功能:把滿足條件的一級代理商轉帳信息導入數據庫 End
*/