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
1.5k232638
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
on target.name=sourceData.c1
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
40.2k362550822
accept rate: 34%

edited 11 Jan '12, 03:12

Martin's gravatar image

Martin
9.0k130169257

Your answer
toggle preview

Follow this question

By Email:

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

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "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:

×119
×36
×12
×2

question asked: 10 Jan '12, 16:30

question was seen: 2,827 times

last updated: 11 Jan '12, 03:12