on ‎2014 Sep 09 9:42 PM
Hi all, I can't seem to figure this one out so maybe someone has hit the same issue. I am guessing it's a syntax problem.
UPSERT works fine when dealing with a single row, but I can't get this to work for a subquery.
Works fine
UPSERT <TABLE> (COLUMN1, COLUMN2) VALUES ('VALUE1', 'VALUE2') WITH PRIMARY KEY;
Syntax error near "PRIMARY"
UPSERT <TABLE> (COLUMN1, COLUMN2) VALUES (SELECT COLUMN1, COLUMN2 FROM TABLE2) WITH PRIMARY KEY;
Same thing tried another way
UPSERT <TABLE> (COLUMN1, COLUMN2) (SELECT COLUMN1, COLUMN2 FROM TABLE2) WITH PRIMARY KEY;
I have used this successfully before with INSERT, but I am thinking the UPSERT is a slightly different animal.
Regards,
Justin
Request clarification before answering.
Actually there is a better way of doing Upsert. Try the MERGE statement. It does the same Update or Insert, with easily coding.
https://help.sap.com/viewer/4fe29514fd584807ac9f2a04f6754767/2.0.02/en-US/3226201f95764a57810dd256c9...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 9 | |
| 5 | |
| 4 | |
| 4 | |
| 3 | |
| 3 | |
| 2 | |
| 2 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.