Please be aware that the content in SAP SQL Anywhere Forum will be migrated to the SAP Community in June and this forum will be retired.

Does anyone know a way (perhaps I'm overlooking it) to make the ON EXISTING SKIP syntax check Alternate Keys?

If there isn't a 'built-in' way, I'd like to suggest this as a feature!

Thanks, Calvin

asked 10 Jan '12, 16:30

Calvin%20Allen's gravatar image

Calvin Allen
accept rate: 25%

AFAIK, INSERT ON EXISTING does rely on the primary key.

However, the much more powerful MERGE statement - available with v11 and above - can be used with different key sets, cf. this FAQ. Furthermore, it's part of the SQL/2008 standard whereas the INSERT ON EXISTING clause is not.

Based on Volkers answer here an example how to use the merge statement with static values and no source table:

merge into target
using (select 'NewName' c1) as sourceData
when matched then skip
when not matched then insert ( "Name" , "Description" ) values ('NewName','test')
permanent link

answered 10 Jan '12, 17:29

Volker%20Barth's gravatar image

Volker Barth
accept rate: 34%

edited 11 Jan '12, 03:12

Martin's gravatar image


Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:


question asked: 10 Jan '12, 16:30

question was seen: 2,842 times

last updated: 11 Jan '12, 03:12