Question : How to set values of items based on the value of another item.  Trigger?

Hi - I am using Oracle APEX 4.0.  I need to set the value of an item based on the value of another item.  I am able to get the sql to work, but can't figure out where to put it.

Below are the conditions and the desired values:

IF Emp_status = "started" then Headcount = "yes"
IF Role_status = On Board  then Headcount = "yes"
IF Role_status = Open Position then Headcount = "no"
If Role_status = Is Null then Headcount = "no"

I've tried several approaches, but can't find the right solution. I'm thinking a trigger on the table (hiring_tbl) that would fire before insert or update, but cannot ge the syntax right.

Any help is welcome!
Thanks!
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
create or replace trigger SET_HEADCOUNT_TRIG  
  before insert on HIRING_TBL_TESTING              
  for each row
begin  
  if     :new.HIRING_STATUS = 'Started'
         :new.HEADCOUNT := 'Yes';
  elseif :new.ROLE_STATUS = 'On Board'
         :new.HEADCOUNT := 'Yes';
  elseif :new.ROLE_STATUS = 'Open Position'
         :new.HEADCOUNT := 'No';
  elseif :new.ROLE_STATUS IS NULL
         :new.HEADCOUNT := 'No';
  end if;
end;

Answer : How to set values of items based on the value of another item.  Trigger?

But for the syntax error : change elseif to ELSIF

create or replace trigger SET_HEADCOUNT_TRIG  
  before insert on HIRING_TBL_TESTING              
  for each row
begin  
  if     :new.HIRING_STATUS = 'Started' THEN
         :new.HEADCOUNT := 'Yes';
  elsif :new.ROLE_STATUS = 'On Board' THEN
         :new.HEADCOUNT := 'Yes';
  elsif :new.ROLE_STATUS = 'Open Position' THEN
         :new.HEADCOUNT := 'No';
  elsif :new.ROLE_STATUS IS NULL THEN
         :new.HEADCOUNT := 'No';
  end if;
end;
/
Random Solutions  
 
programming4us programming4us