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.
-
You've written SQL Server in your title and tagged Oracle? What is your question?Ben– Ben2013-06-28 09:43:02 +00:00Commented Jun 28, 2013 at 9:43
-
I need a common query to update multiple columns of a table in sql server and oracle .Rakesh Devarasetti– Rakesh Devarasetti2013-06-28 09:45:57 +00:00Commented 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.Serge– Serge2013-06-28 09:53:59 +00:00Commented Jun 28, 2013 at 9:53
2 Answers
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
Comments
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.