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 '17, 09:41

Walmir%20Taques's gravatar image

Walmir Taques
690374051
accept rate: 12%

edited 27 Jun '17, 10:03

Volker%20Barth's gravatar image

Volker Barth
39.7k358546815


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 '17, 09:50

Reg%20Domaratzki's gravatar image

Reg Domaratzki
7.6k343115
accept rate: 37%

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 '17, 09:50

Mark%20Culp's gravatar image

Mark Culp
24.8k10139296
accept rate: 41%

2

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

(27 Jun '17, 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:

×107
×38
×34

question asked: 27 Jun '17, 09:41

question was seen: 1,733 times

last updated: 27 Jun '17, 10:03