在ORACLE 建立存储过程,方法如下: 第一步: CREATE OR REPLACE PACKAGE PKG_AIMQ231 IS TYPE P_CURSOR IS REF CURSOR; PROCEDURE PROC_AIMQ231(P_DB in varchar2,P_DATE in date, P_LIAO in varchar2, P_CANG in varchar2,P_CHU in varchar2, P_PI in varchar2, P_DATA OUT PKG_AIMQ231.P_CURSOR); END PKG_AIMQ231 第二步: CREATE OR REPLACE PACKAGE BODY PKG_AIMQ231 IS PROCEDURE PROC_AIMQ231(P_DB in varchar2,P_DATE in date, P_LIAO in varchar2, P_CANG in varchar2,P_CHU in varchar2, P_PI in varchar2, P_DATA OUT PKG_AIMQ231.P_CURSOR) IS BEGIN OPEN P_DATA FOR IF to_char(P_DATE,'mm') = '01' THEN SELECT tlf01,ima02,ima021,ima08, year(tlf06) as year,month(tlf06) as month, tlf06,tlf026,tlf036,tlf10, tlf11,tlf024,tlf907,tlf13,tlf08,imk09,img10 FROM P_DB.tlf_file left join P_DB.ima_file on tlf01=ima01 left join P_DB.img_file on tlf01=img01 and tlf902=img02 and tlf903=img03 and tlf904=img04 left join P_DB.imk_file on tlf01=imk01 and tlf902=imk02 and tlf903=imk03 and tlf904=imk04 and imk05=to_char(to_date('P_DATE','yyyy-mm-dd'),'yyyy')-1 and imk06=12 WHERE tlf01 = P_LIAO AND (tlf907 <> 0) AND tlf902 = P_CANG AND tlf903 = P_CHU AND tlf904 = P_PI AND tlf06 >= to_date('P_DATE','YYYY-MM-DD') order by tlf06; ELSIF SELECT tlf01,ima02,ima021,ima08, year(tlf06) as year,month(tlf06) as month, tlf06,tlf026,tlf036,tlf10, tlf11,tlf024,tlf907,tlf13,tlf08,imk09,img10 FROM P_DB.tlf_file left join P_DB.ima_file on tlf01=ima01 left join P_DB.img_file on tlf01=img01 and tlf902=img02 and tlf903=img03 and tlf904=img04 left join P_DB.imk_file on tlf01=imk01 and tlf902=imk02 and tlf903=imk03 and tlf904=imk04 and imk05=to_char(to_date('P_DATE','yyyy-mm-dd'),'yyyy') and imk06=to_char(to_date('P_DATE','yyyy-mm-dd'),'mm')-1 WHERE tlf01 = P_LIAO AND (tlf907 <> 0) AND tlf902 = P_CANG AND tlf903 = P_CHU AND tlf904 = P_PI AND tlf06 >= to_date('P_DATE','YYYY-MM-DD') order by tlf06; END IF; END; END PKG_AIMQ231; 第三部在FR调用: 第四步预览: 报错如下,帮我看看哪里有问题? |