ORA-01741:sql plus 的非法零长度标识符

问题描述 投票:0回答:1

您好,我尝试使用 sql plus 执行此查询,但收到错误 ORA-01741:非法零长度标识符。你能帮忙解决一下吗?

INSERT INTO FCCR_DATA_MAPPING(ID_API,DATA,COLUMN_NAME,TABLE_NAME,CONDITION,REQ_COMPLETE,REQ_COMPLETE_EXT) VALUES('compute','customer-rating-rawData-ultimateBeneficialOwners',null,null,null,'SELECT '{ "firstName": "XXXX"' ||', "lastName": "XXXX"' ||', "birthDate": "' || CASE b.typ WHEN 'C' THEN (SELECT to_char(c3.dna,'yyyy-mm-dd') FROM bkcli c3 WHERE c3.cli=b.beneff) WHEN 'T' 
THEN (SELECT to_char(t3.dna,'yyyy-mm-dd') FROM bktier t3 WHERE t3.ctie=b.beneff) END || '"' ||', "residenceCountryCode": "' || CASE b.typ WHEN 'C' THEN (SELECT trim(nc4.lib2) 
    FROM bkcli c4, bknom nc4 WHERE c4.cli=b.beneff AND nc4.cacc=c4.res AND nc4.ctab='040') WHEN 'T' THEN (SELECT trim(nt4.lib2) FROM bktier t4, bknom nt4 WHERE t4.ctie=b.beneff 
    AND nt4.cacc=t4.res AND nt4.ctab='040') END || '"' ||', "localResidenceCountryCode": ""' ||', "birthCountryCode": "' || CASE b.typ WHEN 'C' THEN (SELECT trim(nc6.lib2) FROM bkcli c6, 
    bknom nc6 WHERE c6.cli=b.beneff AND nc6.cacc=c6.payn AND nc6.ctab='040') WHEN 'T' THEN (SELECT trim(nt6.lib2) FROM bktier t6, bknom nt6 WHERE t6.ctie=b.beneff AND nt6.cacc=t6.payn AND nt6.ctab='040') 
    END || '"' ||', "gender": "' || CASE b.typ WHEN 'C' THEN (CASE (SELECT trim(c7.sext) FROM bkcli c7 WHERE c7.cli=b.beneff) WHEN 'M' THEN 'MALE' WHEN 'F' THEN 'FEMALE' ELSE 'INDEFINITE' END) WHEN 'T' 
    THEN (CASE (SELECT trim(t7.sext) FROM bktier t7 WHERE t7.ctie=b.beneff) WHEN 'M' THEN 'MALE' WHEN 'F' THEN 'FEMALE' ELSE 'INDEFINITE' END) END || '"' ||', "localBirthCountryCode": ""' ||' }' 
    FROM abbeneff b WHERE b.actif="O" and b.cli=?',null);
COMMIT;

语法正确,我无法更改逗号...

oracle sqlplus
1个回答
0
投票

整齐地格式化您的代码:

INSERT INTO FCCR_DATA_MAPPING(
  ID_API,
  DATA,
  COLUMN_NAME,
  TABLE_NAME,
  CONDITION,
  REQ_COMPLETE,
  REQ_COMPLETE_EXT
) VALUES(
  'compute',
  'customer-rating-rawData-ultimateBeneficialOwners',
  null,
  null,
  null,
  'SELECT '{ "firstName": "XXXX"'
  ||', "lastName": "XXXX"'
  ||', "birthDate": "'
  || CASE b.typ
     WHEN 'C' THEN (SELECT to_char(c3.dna,'yyyy-mm-dd') FROM bkcli c3 WHERE c3.cli=b.beneff)
     WHEN 'T' THEN (SELECT to_char(t3.dna,'yyyy-mm-dd') FROM bktier t3 WHERE t3.ctie=b.beneff)
     END
  || '"'
  || ', "residenceCountryCode": "'
  || CASE b.typ
     WHEN 'C' THEN (SELECT trim(nc4.lib2) FROM bkcli c4, bknom nc4 WHERE c4.cli=b.beneff AND nc4.cacc=c4.res AND nc4.ctab='040')
     WHEN 'T' THEN (SELECT trim(nt4.lib2) FROM bktier t4, bknom nt4 WHERE t4.ctie=b.beneff AND nt4.cacc=t4.res AND nt4.ctab='040')
     END
  || '"'
  ||', "localResidenceCountryCode": ""'
  ||', "birthCountryCode": "'
  || CASE b.typ
     WHEN 'C' THEN (SELECT trim(nc6.lib2) FROM bkcli c6, bknom nc6 WHERE c6.cli=b.beneff AND nc6.cacc=c6.payn AND nc6.ctab='040')
     WHEN 'T' THEN (SELECT trim(nt6.lib2) FROM bktier t6, bknom nt6 WHERE t6.ctie=b.beneff AND nt6.cacc=t6.payn AND nt6.ctab='040') 
     END
  || '"'
  ||', "gender": "'
  || CASE b.typ
     WHEN 'C' THEN (CASE (SELECT trim(c7.sext) FROM bkcli c7 WHERE c7.cli=b.beneff)
                    WHEN 'M' THEN 'MALE'
                    WHEN 'F' THEN 'FEMALE'
                    ELSE 'INDEFINITE'
                    END)
     WHEN 'T' THEN (CASE (SELECT trim(t7.sext) FROM bktier t7 WHERE t7.ctie=b.beneff)
                    WHEN 'M' THEN 'MALE'
                    WHEN 'F' THEN 'FEMALE'
                    ELSE 'INDEFINITE'
                    END) END
  || '"'
  ||', "localBirthCountryCode": ""'
  ||' }' FROM abbeneff b WHERE b.actif="O" and b.cli=?',
  null
);
COMMIT;

然后看

REQ_COMPLETE
值,第一行:

'SELECT '{ "firstName": "XXXX"'

最后一行:

||' }' FROM abbeneff b WHERE b.actif="O" and b.cli=?',

两者都有 3 个引号,并且应该是:

(SELECT '{ "firstName": "XXXX"'
...
||' }' FROM abbeneff b WHERE b.actif="O" and b.cli=?),

或:

'SELECT ''{ "firstName": "XXXX"'
...
||' }'' FROM abbeneff b WHERE b.actif="O" and b.cli=?',

(在后一种情况下,您还需要转义

CASE
表达式中的引号)。

© www.soinside.com 2019 - 2024. All rights reserved.