请问这个函数有什么问题:我得到这个错误:遇到符号“CFCE”时,预期以下之一:= .(@ % ;注意:当我在声明部分声明游标没有错误,但我需要在异常部分声明它
CREATE OR REPLACE FUNCTION PMISHR.SYS_ENCASH_FC
(
PRM_POLICY_KEY VARCHAR2,
PRM_POLDEBTOR_SEQ NUMBER,
PRM_SYSTEMIND VARCHAR2 DEFAULT 'G',
PRM_AGTBDX_DATE DATE
)
RETURN VARCHAR2 IS
--V_FC_PREMIUM VARCHAR2(3000 BYTE);
V_FC_PREMIUM CLOB :='';
BEGIN
IF PRM_SYSTEMIND = 'G' THEN
BEGIN
/* AUTO RECONCILIATION */
SELECT AGB_COMP_REF_NO
INTO V_FC_PREMIUM
FROM CDNOTE_RECONCILE_DATA, CDNOTE, AGENTVOBRX, AGENTBORDEREAUX, GENPOLDEBTOR
WHERE CDR_RECONCILE_SOURCE = 'GENPOLICY'
AND CDR_RECONCILE_SOURCE = CDN_SOURCE_TABLE
AND NVL(CDR_MANUALRECONCILE_IND,'N') = 'N'
AND CDN_SOURCE_CDE = POL_POLICY_CDE
AND CDN_SOURCE_SEQ = POL_POLDEBTOR_SEQ
AND POL_POLICY_CDE = PRM_POLICY_KEY
AND POL_POLDEBTOR_SEQ = PRM_POLDEBTOR_SEQ
AND CDR_CDNOTE_TYPE = CDNOTE_TYPE
AND CDR_CDN_NUMBER_SYSTEM = CDNOTE_NUMBER
AND ((CDR_VO_BRX_PREM_CDN_TYPE = AVO_CDNOTE_TYPE AND AVO_CDNOTE_NUMBER = CDR_CDN_NUMBER_VO_BRX)
OR (CDR_CDN_NUMBER_VO_BRX IS NULL AND CDR_PREMIUMS_VO_CDE = AVO_PREMIUMSVO_CDE)
)
AND AVO_AGENTBORDEREAUX_CDE = AGENTBORDEREAUX_KEY
AND TRUNC(AGENTBORDEREAUX.A_DATE_TIME_CREATED) <= TRUNC(PRM_AGTBDX_DATE)
AND ROWNUM<=1;
EXCEPTION
WHEN NO_DATA_FOUND THEN
/* MANUAL RECONCILIATION */
CURSOR cFCE(PRM_POLICY_KEY VARCHAR2,PRM_POLDEBTOR_SEQ NUMBER) IS
SELECT AGB_COMP_REF_NO
FROM MANUALPREMIUM_RECONCILE, CDNOTE_RECONCILE_DATA, CDNOTE, AGENTVOBRX, AGENTBORDEREAUX
WHERE CDNOTE.CDN_SOURCE_TABLE = 'GENPOLICY'
AND CDNOTE.CDN_SOURCE_CDE = PRM_POLICY_KEY
AND CDNOTE.CDN_SOURCE_SEQ = PRM_POLDEBTOR_SEQ
AND CDR_CDNOTE_TYPE = CDNOTE_TYPE
AND CDR_CDN_NUMBER_SYSTEM = CDNOTE_NUMBER
AND CDR_RECONCILE_WITH = 'AGENTVOBRX'
AND NVL(CDR_MANUALRECONCILE_IND,'N') = 'Y'
AND CDR_MANUALRECONCILE_BATCH_CDE = MPR_RECONCILE_BATCH_ID
AND CDR_VO_BRX_PREM_CDN_TYPE = AVO_CDNOTE_TYPE
AND AVO_CDNOTE_NUMBER = CDR_CDN_NUMBER_VO_BRX
AND AVO_AGENTBORDEREAUX_CDE = AGENTBORDEREAUX_KEY
AND MPR_CDNOTE_TYPE = CDR_CDNOTE_TYPE
AND MPR_CDNOTE_NUMBER = CDR_CDN_NUMBER_SYSTEM
AND TRUNC(AGENTBORDEREAUX.A_DATE_TIME_CREATED) <= TRUNC(PRM_AGTBDX_DATE)
AND AGB_VALID_IND = 'Y'
;
rFCE cFCE%ROWTYPE;
OPEN cFCE(PRM_POLICY_KEY,PRM_POLDEBTOR_SEQ);
LOOP
FETCH cFCE INTO rFCE;
EXIT WHEN cFCE%NOTFOUND;
V_FC_PREMIUM := V_FC_PREMIUM || rFCE.AGB_COMP_REF_NO || ' ; ';
END LOOP;
CLOSE cFCE;
if length(V_FC_PREMIUM)>4000 then V_FC_PREMIUM:= substr(V_FC_PREMIUM,1,4000); end if;
END;
RETURN V_FC_PREMIUM;
ELSE
BEGIN
/* AUTO RECONCILIATION */
SELECT AGB_COMP_REF_NO
INTO V_FC_PREMIUM
FROM CDNOTE_RECONCILE_DATA, CDNOTE, AGENTVOBRX, AGENTBORDEREAUX, LIFEPOLDEBTOR
WHERE CDR_RECONCILE_SOURCE = 'LIFE_POLICY'
AND CDR_RECONCILE_SOURCE = CDN_SOURCE_TABLE
AND NVL(CDR_MANUALRECONCILE_IND,'N') = 'N'
AND CDN_SOURCE_CDE = POL_POLICY_CDE
AND CDN_SOURCE_SEQ = POL_POLDEBTOR_SEQ
AND POL_POLICY_CDE = PRM_POLICY_KEY
AND POL_POLDEBTOR_SEQ = PRM_POLDEBTOR_SEQ
AND CDR_CDNOTE_TYPE = CDNOTE_TYPE
AND CDR_CDN_NUMBER_SYSTEM = CDNOTE_NUMBER
AND CDR_VO_BRX_PREM_CDN_TYPE = AVO_CDNOTE_TYPE
AND AVO_CDNOTE_NUMBER = CDR_CDN_NUMBER_VO_BRX
AND AVO_AGENTBORDEREAUX_CDE = AGENTBORDEREAUX_KEY
AND TRUNC(AGENTBORDEREAUX.A_DATE_TIME_CREATED) <= TRUNC(PRM_AGTBDX_DATE)
AND ROWNUM<=1;
EXCEPTION
WHEN NO_DATA_FOUND THEN
/* MANUAL RECONCILIATION */
SELECT AGB_COMP_REF_NO
INTO V_FC_PREMIUM
FROM MANUALPREMIUM_RECONCILE, CDNOTE_RECONCILE_DATA, CDNOTE, AGENTVOBRX, AGENTBORDEREAUX
WHERE CDNOTE.CDN_SOURCE_TABLE = 'LIFE_POLICY'
AND CDNOTE.CDN_SOURCE_CDE = PRM_POLICY_KEY
AND CDNOTE.CDN_SOURCE_SEQ = PRM_POLDEBTOR_SEQ
AND CDR_CDNOTE_TYPE = CDNOTE_TYPE
AND CDR_CDN_NUMBER_SYSTEM = CDNOTE_NUMBER
AND CDR_RECONCILE_WITH = 'AGENTVOBRX'
AND NVL(CDR_MANUALRECONCILE_IND,'N') = 'Y'
AND CDR_MANUALRECONCILE_BATCH_CDE = MPR_RECONCILE_BATCH_ID
AND CDR_VO_BRX_PREM_CDN_TYPE = AVO_CDNOTE_TYPE
AND AVO_CDNOTE_NUMBER = CDR_CDN_NUMBER_VO_BRX
AND AVO_AGENTBORDEREAUX_CDE = AGENTBORDEREAUX_KEY
AND MPR_CDNOTE_TYPE = CDR_CDNOTE_TYPE
AND MPR_CDNOTE_NUMBER = CDR_CDN_NUMBER_SYSTEM
AND TRUNC(AGENTBORDEREAUX.A_DATE_TIME_CREATED) <= TRUNC(PRM_AGTBDX_DATE)
AND AGB_VALID_IND = 'Y'
AND ROWNUM<=1;
END;
RETURN V_FC_PREMIUM;
END IF;
END;
/
字符串
我有这个错误
遇到符号“CFCE”时,预期以下之一:= .(@ % ;注意:当我在第一节中声明游标时,没有问题,但由于性能问题,我需要在异常节中声明它
4条答案
按热度按时间dbf7pr2w1#
通过阅读评论,我发现您找到了一个解决方法(
listagg
函数;注意,如果结果字符串超过4000个字符,它将无法工作)。至于另一个评论/回答说,你不能在异常处理部分声明游标-好吧,这是不正确的。你可以,但你必须以支持的方式来做,通过包括
declare
关键字。下面是一个例子;请参阅代码中的注解。
字符串
nsc4cvqm2#
不允许在异常节中声明游标。您可以尝试在声明节中声明游标,然后通过在异常节中获取来使用它。
mpgws1up3#
如果你要使用
CURSOR
,那么它需要在PL/SQL块的DECLARE
部分:字符串
blmhpbnm4#
谢谢你们的回答。我用了函数LISTAGG,它解决了我的问题