Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Feature suggestion: With clause with update

j.siebenJan 3 2012 — edited Jan 3 2012
Hi everybody,
I'd like to ask whether you could imagine that it would be a good enhancement to SQL to have the possibility to use the with clause together with the update statement?

What I'm coming across frequently is that I need to repeat a subquery over and over again when trying to calculate values for an update. So I would suggest to have a possibility to write something in the line of

<pre>with vals as (select key, col1, col2, col3 from some_table
update table_foo f
set col1 = (select col1 from vals where f.key = vals.key),
col2 = (select col1 from vals where f.key = vals.key)
where col3 in (select col3 from vals);</pre>

What do you think? Or: Am I missing the point here and an easier way of doing this is avialable already?

Best regards

Jürgen
This post has been answered by Etbin on Jan 3 2012
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 31 2012
Added on Jan 3 2012
4 comments
412 views