Error in Merge: Syntax error, expected something like '(' between the 'USING' keyword and the word 'Database_2'.'.

Database
Fan

Error in Merge: Syntax error, expected something like '(' between the 'USING' keyword and the word 'Database_2'.'.

My procedure contains the following merge statement.

 MERGE INTO "Database_1".Status RPT
USING "Database_2".Status STG
ON (RPT.ID = STG.ID
AND RPT.STATE = STG.STATE)
WHEN MATCHED THEN
UPDATE SET
UPDATE_DATE = STG.UPDATE_DATE
WHEN NOT MATCHED THEN
INSERT
VALUES (STG.ID, STG.STATE, STG.UPDATE_DATE);

Even though the syntax of the Merge statement seems to be proper, I get the error "Missing/Invalid SQL statement'E(3707):Syntax error, expected something like '(' between the 'USING' keyword and the word 'Database_2'.'. "

Can someone point me towards the issue?

Thanks

3 REPLIES
Fan

Re: Error in Merge: Syntax error, expected something like '(' between the 'USING' keyword and the word 'Database_2'.'.

reposting the code

MERGE INTO "Database_1".Status RPT
USING "Database_2".Status STG
ON (RPT.ID = STG.ID
AND RPT.STATE = STG.STATE)
WHEN MATCHED THEN
UPDATE SET
UPDATE_DATE = STG.UPDATE_DATE
WHEN NOT MATCHED THEN
INSERT
VALUES (STG.ID, STG.STATE, STG.UPDATE_DATE);

bwb
Teradata Employee

Re: Error in Merge: Syntax error, expected something like '(' between the 'USING' keyword and the word 'Database_2'.'.

Looks OK to me. A suggestion: since your database names don't need the quotation marks (LOW LINE is valid in names without the quotes), try the query without them. If it works, then you have a workaround. Whether or not it works without the quotes, you should report the problem to Teradata support (if it's something trivial that we've both missed, you'll hopefully get a resolution, and if it's some kind of parsing bug, it can be addressed [be sure to state whether or not the quoteless variant worked]). Good luck!

Fan

Re: Error in Merge: Syntax error, expected something like '(' between the 'USING' keyword and the word 'Database_2'.'.

The quoteless version did not work. will report it to Teradata support. Thanks for your help bwb.