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.

Problem with understanding case statement

user-wjq74Jul 20 2023 — edited Jul 20 2023

Hello, I have a problem with understanding case statement. I want to set particular salary values for certain groups of employeeids (for example: when emploeeid is in (2,3,4) then i want their salary to be 200). Table: emp1, Columns: employeeid, salary

The code that works looks like that:

update emp1
set salary =
case
when employeeid in (2,3,4) then 200
when employeeid in (5,6,7) then 1200
when employeeid in (8,9,10)then 3200
else 6000
end;

but why is it like that and not like (for example) that:

case
when employeeid in (2,3,4) then update emp1 set salary = 200
when employeeid in (5,6,7) then update emp1 set salary = 1200
when employeeid in (8,9,10)then update emp1 set salary = 3200
else update emp1 set salary = 6000
end;

Can someone explain me why is it constructed like that?

This post has been answered by Frank Kulash on Jul 20 2023
Jump to Answer
Comments
Post Details
Added on Jul 20 2023
3 comments
208 views