PL / SQL连接数据

时间:2013-12-03 06:04:28

标签: sql stored-procedures plsql syntax-error

我遇到了将我的PLC / SQL程序连接到我的代码出错的问题,我应该做什么基础?

IF iReceiptTotal > 0 THEN
    @con := ' AND a.MUNC_ID = ' || "'" ||iMuncID ||"'" ||' AND TO_DATE(IF(' ||"'" ||iManual || "'" || "='AUTO'," ||'a.TPAY_ISSUED_DATE, a.MANUAL_COLLECTION_DATE),"'"yyyy/mm/dd hh24:mi:ss"'") <= TO_DATE(SYSTIMESTAMP(),'yyyy/mm/dd hh24:mi:ss am') AND TPAY_CANCELLED_STATUS = ',"'0'", ' AND TPAY_NO_PAYMENT = ',"'0'", ' ORDER BY LOC_NO LIMIT ', xLimit);
ELSE
    @con := ' AND a.MUNC_ID = ' || "'" ||iMuncID ||"'" ||' AND TO_DATE(IF(' ||"'" ||iManual || "'" || "='AUTO'," ||'a.TPAY_ISSUED_DATE, a.MANUAL_COLLECTION_DATE),"'"yyyy/mm/dd hh24:mi:ss am"'") <= DATE_FORMAT(SYSTIMESTAMP(),"'"yyyy/mm/dd hh24:mi:ss"'") AND TPAY_CANCELLED_STATUS = ',"'0'", ' AND TPAY_NO_PAYMENT = ',"'0'", ' ORDER BY LOC_NO LIMIT ', xLimit);
END IF;
@q := 'UPDATE tbl_tax_payment a SET a.BCS_TYPE= ' || "'" ||xType ||"'" ||',a.BCS_NO = ' || "'" ||xBCS ||"'" || ', a.BCS_COUNTER= ' || "'" ||xMax ||"'" ||' WHERE a.RECEIPT_TYPE =' ||"'" ||iReceipt ||"'" || ' AND a.LOC_NO IS NOT NULL AND a.BCS_NO IS NULL AND a.RCO_CODE = ' ||"'" ||iRCO ||"'" || @con;
                        EXECUTE IMMEDIATE  @q;
                        DEALLOCATE PREPARE st;
  

这是我的错误   符号@被忽略了   PLS-00103:遇到符号“yyy / mm / dd / hh24:mi:ss”时遇到字符... like4 likec在成员submultiset之间。

这意味着什么?

1 个答案:

答案 0 :(得分:0)

您必须将"'"yyyy/mm/dd hh24:mi:ss"'"更改为''yyyy/mm/dd hh24:mi:ss''

同样,您必须将所有"'"更改为''

查询已编辑

IF iReceiptTotal > 0 THEN
   @con := ' AND a.MUNC_ID = ' || '''' ||iMuncID ||'''' ||' AND TO_DATE(IF(' ||'''' ||iManual || '''' || '=''AUTO'',' ||'a.TPAY_ISSUED_DATE, a.MANUAL_COLLECTION_DATE),''yyyy/mm/dd hh24:mi:ss'') <= TO_DATE(SYSTIMESTAMP(),''yyyy/mm/dd hh24:mi:ss am'') AND TPAY_CANCELLED_STATUS = ',''0'', ' AND TPAY_NO_PAYMENT = ',''0'', ' ORDER BY LOC_NO LIMIT ', xLimit);
ELSE
   @con := ' AND a.MUNC_ID = ' || '''' ||iMuncID ||'''' ||' AND TO_DATE(IF(' ||'''' ||iManual || '''' || '=''AUTO'',' ||'a.TPAY_ISSUED_DATE, a.MANUAL_COLLECTION_DATE),''yyyy/mm/dd hh24:mi:ss am'') <= TO_DATE(SYSTIMESTAMP(),''yyyy/mm/dd hh24:mi:ss'') AND TPAY_CANCELLED_STATUS = ',''0'', ' AND TPAY_NO_PAYMENT = ',''0'', ' ORDER BY LOC_NO LIMIT ', xLimit);
  END IF;
  @q := 'UPDATE tbl_tax_payment a SET a.BCS_TYPE= ' || '''' ||xType ||'''' ||',a.BCS_NO = ' || '''' ||xBCS ||'''' || ', a.BCS_COUNTER= ' || '''' ||xMax ||'''' ||' WHERE a.RECEIPT_TYPE =' ||'''' ||iReceipt ||'''' || ' AND a.LOC_NO IS NOT NULL AND a.BCS_NO IS NULL AND a.RCO_CODE = ' ||'''' ||iRCO ||'''' || @con;
                        EXECUTE IMMEDIATE  @q;
                        DEALLOCATE PREPARE st;