Home » SQL & PL/SQL » SQL & PL/SQL » Can we use case stmt in update stmt
Can we use case stmt in update stmt [message #273644] Thu, 11 October 2007 03:14 Go to next message
Messages: 24
Registered: October 2007
Location: Bangalore
Junior Member

I want to update salary column of emp table based on condition.
I am doing like this:

update emp
set sal in(select case sal when sal<100 then sal*.01
when sal between 100 and 200
then sal*.02
when sal between 201 and 300
then sal*.03
else sal end)
but it is giving error missing equal sign in place of in.
If I give = then it will not work as subquery returns multiple rows.
Please help me regarding this..
Re: Can we use case stmt in update stmt [message #273654 is a reply to message #273644] Thu, 11 October 2007 03:52 Go to previous message
Messages: 7062
Registered: December 2001
Senior Member
Tip 1: read the Forum Guidelines (in the yellow bar on top of each forum).
Tip 2: Oracle is right. You are missing an equal sign (=). Look up the syntax of the UPDATE statement.
Tip 3: People won't be happy if you are cutting salaries like that Wink
Tip 4: you are mixing 2 case flows
Tip 5: You have an 'END' too many
Tip 6: you don't need to use an inner select. You want to evaluate a column from the selected row itself.
Tip 7: this is hardly expert.

Is this by any chance a homework assignment?

Previous Topic: order by
Next Topic: getting count of non-zero, non-null values per row
Goto Forum:

Current Time: Fri Oct 21 15:44:34 CDT 2016

Total time taken to generate the page: 0.19667 seconds