Oracle - Updating one column or another based on a condition
- by z-dan
I want to update a record in a table but based on a condition I will either update one column or another but I do not want to have 2 separate statements because the statements are very long and detailed. 
Here is the basic idea with over simplification to get to the point. 
PROCEDURE Animal_something(p_updater VARCHAR2)
begin
  if p_updater = 'person' then   
    -- I want to update the modified_by  
  else   
    -- if p_updater = 'a process' I want to update modified_by_process
Update table_creatures
   set animal_type = 'Dog ,
**modified_by** = 'Bob'   
**or do this**  
**modified_by_process =** 'creature_package'
 where animal_legs = '4'
I don't want:
if p_updater = 'person' then 
  Update table_creatures   
     set animal_type = 'Dog ,  
         modified_by = 'Bob'  
   where animal_legs = '4';  
else  
  Update table_creatures  
     set animal_type = 'Dog , 
         modified_by_process = 'creature_package'  
   where animal_legs = '4';
end;