2

Is it possible to get common query for updating multiple columns in table in sql and oracle . Instead of modifying separate queries with provider type.

Update multiple columns in SQL

3
  • You've written SQL Server in your title and tagged Oracle? What is your question? Commented Jun 28, 2013 at 9:43
  • I need a common query to update multiple columns of a table in sql server and oracle . Commented Jun 28, 2013 at 9:45
  • I'm not well aware on how things work for Oracle, but MERGE should be the way for you to go. Commented Jun 28, 2013 at 9:53

2 Answers 2

0

I guess Oracle is compatible with SQL:2003

You could use

MERGE INTO tablename USING table_reference ON (condition)
WHEN MATCHED THEN
UPDATE SET column1 = value1 [, column2 = value2 ...]

More about MERGE here

Sign up to request clarification or add additional context in comments.

Comments

0

The standard ANSI SQL implementation will work with both sql server and oracle

UPDATE <TABLE Name>
SET Col1 = ColValue[, Col2 = Col2Value, .....];

The only thing that you have to put is a semicolon at the end of update statement, as ";" is mandatory statement terminating operator in oracle, where as it is optional in sql server.

NOTE: The clauses that I put in square brackets ([]) are optional.

NOTE 2: UPDATE..FROM is a properietry syntax used by SQL Server, so it cannot be accepted by oracle..

NOTE 3: UPDATE SET (col1,col2) = Col1,Col2 is a syntax supported by oracle but not by sql server.

2 Comments

I think there's no FROM clause in the ANSI SQL.
@Serge You are correct there is no from clause in the ANSI syntax, my bad.. edited my solution above...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.