I'm writing an application to move data to Sybase and need to perform update / insert operations. In Firebird, I'd use UPDATE OR INSERT (a single statement exemple :

UPDATE OR INSERT INTO TABLES (PK, TABLE) VALUES (PK, TABLE)

But it doesn't seem to be available in Sybase. I know this can be done with multiple statements, but for a couple of reasons, I'm really trying to get this into a single statement.

Any suggestions?

asked 27 Jun, 09:41

Walmir%20Taques's gravatar image

Walmir Taques
625293145
accept rate: 13%

edited 27 Jun, 10:03

Volker%20Barth's gravatar image

Volker Barth
30.9k311457668


INSERT INTO t1(pk, c1) ON EXISTING UPDATE VALUES ('1', 'reg')

Just curious, but SQL Anywhere v9.0.2 has been end-of-lifed for quite some time. Did you consider using a version of SQL Anywhere that is more recent? We're currently at v17.

Reg

permanent link

answered 27 Jun, 09:50

Reg%20Domaratzki's gravatar image

Reg Domaratzki
5.4k33578
accept rate: 40%

Take a look a the INSERT ... ON EXISTING UPDATE statement in the docs (link is to v10.0.1 docs... so not sure if this is in v9?). This should do what you are wanting to do.

permanent link

answered 27 Jun, 09:50

Mark%20Culp's gravatar image

Mark Culp
23.2k9132273
accept rate: 40%

2

AFAIK, v10 introduced the DEFAULTS ON/OFF clause, so the basic INSERT ON EXISTING UPDATE clause should be way older.

(27 Jun, 09:54) Volker Barth
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:

×100
×31
×29

question asked: 27 Jun, 09:41

question was seen: 90 times

last updated: 27 Jun, 10:03