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!

"WITH CLAUSE" and UPDATE St.

556287Jan 15 2007 — edited Jan 17 2007

Hello Every One,
I have With clause and it is returning multiple results. I want to use this WITH statement( which calculates sal on diff criteria) for UPDATION of table. How can I use it ? Or do I have to use pl/sql for the calculation and the update statement. as it is returning Multiple rows for each ID1 and ID2.
Can any one please suggest me with small sample code.
How to use WITH clause to update the table
It has three column Composit key. ID!,ID2,Name
I want to update sal of each row depending on row retuned by with clause
The below code is just to show what I need to do..

Update  emp x set sal= 
                       (with with_sal as
                            (select id1,id2,name,sal from emp)
                                select  sal from with_sal 
                                 where x.id1=with_name.id1
                                  AND x.id2=with_name.id2
                                  AND x.name=with_name.name
                        )
                               
Thank you in advance

null                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 14 2007
Added on Jan 15 2007
64 comments
3,405 views