I have a button to merge data from one table to another. The problem is the semi-colon…Can someone tell me where the semi-colon goes for this to work?
sc_exec_sql(" MERGE Product_Structure as MAIN
USING Product_Structure_[PMdate] as TEMP
ON (MAIN.PARPRT_02 = TEMP.PARPRT_02 And MAIN.COMPRT_02 = TEMP.COMPRT_02)
WHEN MATCHED THEN UPDATE
SET MAIN.EFFDTE_02 = TEMP.EFFDTE_02,
MAIN.FILL01_02 = TEMP.FILL01_02,
MAIN.QTYPER_02 = TEMP.QTYPER_02,
MAIN.QTYCDE_02 = TEMP.QTYCDE_02,
MAIN.LTOSET_02 = TEMP.LTOSET_02,
MAIN.TYPCDE_02 = TEMP.TYPCDE_02,
MAIN.SCRAP_02 = TEMP.SCRAP_02,
MAIN.ECN_02 = TEMP.ECN_02,
MAIN.ACTDTE_02 = TEMP.ACTDTE_02,
MAIN.FILL02_02 = TEMP.FILL02_02,
MAIN.ALTPRT_02 = TEMP.ALTPRT_02,
MAIN.REFDES_02 = TEMP.REFDES_02,
MAIN.MPNSTR_02 = TEMP.MPNSTR_02,
MAIN.MCOMP_02 = TEMP.MCOMP_02,
MAIN.MSITE_02 = TEMP.MSITE_02,
MAIN.UDFKEY_02 = TEMP.UDFKEY_02,
MAIN.UDFREF_02 = TEMP.UDFREF_02,
MAIN.XDFINT_02 = TEMP.XDFINT_02,
MAIN.XDFFLT_02 = TEMP.XDFFLT_02,
MAIN.XDFBOL_02 = TEMP.XDFBOL_02,
MAIN.XDFDTE_02 = TEMP.XDFDTE_02,
MAIN.XDFTXT_02 = TEMP.XDFTXT_02,
MAIN.FILLER_02 = TEMP.FILLER_02,
MAIN.CreatedBy = TEMP.CreatedBy,
MAIN.CreationDate = TEMP.CreationDate,
MAIN.ModifiedBy = TEMP.ModifiedBy,
MAIN.ModificationDate = TEMP.ModificationDate,
MAIN.ALTCDE_02 = TEMP.ALTCDE_02
WHEN NOT MATCHED THEN
INSERT (PARPRT_02,COMPRT_02,EFFDTE_02,FILL01_02,QTYPER_02,QTYCDE_02,LTOSET_02,TYPCDE_02,SCRAP_02,ECN_02,ACTDTE_02,FILL02_02,ALTPRT_02,REFDES_02,MPNSTR_02,MCOMP_02,MSITE_02,UDFKEY_02,UDFREF_02,XDFINT_02,XDFFLT_02,XDFBOL_02,XDFDTE_02,XDFTXT_02,FILLER_02,CreatedBy,CreationDate,ModifiedBy,ModificationDate,ALTCDE_02)
Values(TEMP.PARPRT_02,TEMP.COMPRT_02,TEMP.EFFDTE_02,TEMP.FILL01_02,TEMP.QTYPER_02,TEMP.QTYCDE_02,TEMP.LTOSET_02,TEMP.TYPCDE_02,TEMP.SCRAP_02,TEMP.ECN_02,TEMP.ACTDTE_02,TEMP.FILL02_02,TEMP.ALTPRT_02,TEMP.REFDES_02,TEMP.MPNSTR_02,TEMP.MCOMP_02,TEMP.MSITE_02,TEMP.UDFKEY_02,TEMP.UDFREF_02,TEMP.XDFINT_02,TEMP.XDFFLT_02,TEMP.XDFBOL_02,TEMP.XDFDTE_02,TEMP.XDFTXT_02,TEMP.FILLER_02,TEMP.CreatedBy,TEMP.CreationDate,TEMP.ModifiedBy,TEMP.ModificationDate,TEMP.ALTCDE_02)";);
Error Close
mssql_query(): message: A MERGE statement must be terminated by a semi-colon (;). (severity 15)
mssql_query(): Query failed
Error while accessing the database:
A MERGE statement must be terminated by a semi-colon (;).
{SC_DB_ERROR_INI}View SQL{SC_DB_ERROR_MID} MERGE Product_Structure as MAIN USING Product_Structure_2016Mar171605 as TEMP ON (MAIN.PARPRT_02 = TEMP.PARPRT_02 And MAIN.COMPRT_02 = TEMP.COMPRT_02) WHEN MATCHED THEN UPDATE SET MAIN.EFFDTE_02 = TEMP.EFFDTE_02, MAIN.FILL01_02 = TEMP.FILL01_02, MAIN.QTYPER_02 = TEMP.QTYPER_02, MAIN.QTYCDE_02 = TEMP.QTYCDE_02, MAIN.LTOSET_02 = TEMP.LTOSET_02, MAIN.TYPCDE_02 = TEMP.TYPCDE_02, MAIN.SCRAP_02 = TEMP.SCRAP_02, MAIN.ECN_02 = TEMP.ECN_02, MAIN.ACTDTE_02 = TEMP.ACTDTE_02, MAIN.FILL02_02 = TEMP.FILL02_02, MAIN.ALTPRT_02 = TEMP.ALTPRT_02, MAIN.REFDES_02 = TEMP.REFDES_02, MAIN.MPNSTR_02 = TEMP.MPNSTR_02, MAIN.MCOMP_02 = TEMP.MCOMP_02, MAIN.MSITE_02 = TEMP.MSITE_02, MAIN.UDFKEY_02 = TEMP.UDFKEY_02, MAIN.UDFREF_02 = TEMP.UDFREF_02, MAIN.XDFINT_02 = TEMP.XDFINT_02, MAIN.XDFFLT_02 = TEMP.XDFFLT_02, MAIN.XDFBOL_02 = TEMP.XDFBOL_02, MAIN.XDFDTE_02 = TEMP.XDFDTE_02, MAIN.XDFTXT_02 = TEMP.XDFTXT_02, MAIN.FILLER_02 = TEMP.FILLER_02, MAIN.CreatedBy = TEMP.CreatedBy, MAIN.CreationDate = TEMP.CreationDate, MAIN.ModifiedBy = TEMP.ModifiedBy, MAIN.ModificationDate = TEMP.ModificationDate, MAIN.ALTCDE_02 = TEMP.ALTCDE_02 WHEN NOT MATCHED THEN INSERT (PARPRT_02,COMPRT_02,EFFDTE_02,FILL01_02,QTYPER_02,QTYCDE_02,LTOSET_02,TYPCDE_02,SCRAP_02,ECN_02,ACTDTE_02,FILL02_02,ALTPRT_02,REFDES_02,MPNSTR_02,MCOMP_02,MSITE_02,UDFKEY_02,UDFREF_02,XDFINT_02,XDFFLT_02,XDFBOL_02,XDFDTE_02,XDFTXT_02,FILLER_02,CreatedBy,CreationDate,ModifiedBy,ModificationDate,ALTCDE_02) Values(TEMP.PARPRT_02,TEMP.COMPRT_02,TEMP.EFFDTE_02,TEMP.FILL01_02,TEMP.QTYPER_02,TEMP.QTYCDE_02,TEMP.LTOSET_02,TEMP.TYPCDE_02,TEMP.SCRAP_02,TEMP.ECN_02,TEMP.ACTDTE_02,TEMP.FILL02_02,TEMP.ALTPRT_02,TEMP.REFDES_02,TEMP.MPNSTR_02,TEMP.MCOMP_02,TEMP.MSITE_02,TEMP.UDFKEY_02,TEMP.UDFREF_02,TEMP.XDFINT_02,TEMP.XDFFLT_02,TEMP.XDFBOL_02,TEMP.XDFDTE_02,TEMP.XDFTXT_02,TEMP.FILLER_02,TEMP.CreatedBy,TEMP.CreationDate,TEMP.ModifiedBy,TEMP.ModificationDate,TEMP.ALTCDE_02){SC_DB_ERROR_CLS}Close{SC_DB_ERROR_END}