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

Community
  • 1
  • 1
Rakesh Devarasetti
  • 1,409
  • 2
  • 24
  • 42

2 Answers2

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.

Surendra
  • 711
  • 5
  • 15
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

Serge
  • 6,554
  • 5
  • 30
  • 56