Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Oracle Update and Return a Value

I am having a Update Statement on a large volume table. It updates only one row at a time.

Update MyTable
Set Col1 = Value
where primary key filters

With this update statement gets executed I also want a value in return to avoid a Select Query on a same table to save resources. What will be my syntax to achieve this?

like image 359
Romesh Avatar asked May 27 '13 09:05

Romesh


People also ask

Does update SQL return value?

The update() method returns an integer that indicates the update count for the SQL statement. The updateMany() method returns an array of integers, each integer indicating the update count for a single run of the SQL statement.

Can procedure return a value in Oracle?

A stored procedure does not have a return value but can optionally take input, output, or input-output parameters. A stored procedure can return output through any output or input-output parameter.

What does Current_date return in Oracle?

CURRENT_DATE returns the current date in the session time zone, in a value in the Gregorian calendar of datatype DATE .

What is CHR 10 in Oracle?

CHR(10) is used to insert line breaks, CHR(9) is for tabs, and CHR(13) is for carriage returns.


1 Answers

You can use the RETURNING keyword.

Update MyTable
Set Col1 = Value
where primary key filters
returning column1,column2...
into variable1,variable2...
like image 128
Noel Avatar answered Nov 06 '22 11:11

Noel