0
votes

i'd encountered following error when creating the following trigger. How to resolve the error? Please..

Error at line 6: PLS-00103: Encountered the symbol ")" when expecting one of the following: ( begin case declare end exception exit for goto if loop mod null pragma raise return select update while with

create or replace trigger totalclaimtrig2
after insert on userinfo
for each row
begin
if (:new.sgaji>'2323.41') and (:new.power>1400)  then
(
:new.jumlah_claim := :new.jarak*0.7;
:new.kelas='A';
)

elsif (:new.sgaji>'2323.41') and (:new.power between 1000 and 1400)  then
(
:new.jumlah_claim := :new.jarak*0.6;
:new.kelas='B';
)

elsif (:new.sgaji>'2323.41') and (:new.power between 500 and 1000)  then
(
:new.jumlah_claim := :new.jarak*0.5;
:new.kelas='C';
)

elsif (:new.sgaji>'2323.41') and (:new.power between 175 and 500)  then
(
:new.jumlah_claim := :new.jarak*0.45;
:new.kelas='D';
)

elsif (:new.sgaji>'2323.41') and (:new.power<175)  then
(
:new.jumlah_claim := :new.jarak*0.4;
:new.kelas='E';
)

end if;
end;​
1
Well, for one thing, you don't use parens to block code in PL/SQL. You use BEGIN/END blocks. My suggestion to you is to read some tutorials on PL/SQL first.OldProgrammer

1 Answers

0
votes

Remove all parentheses, use := instead of = for assignments, remove the weird character after the last ;, and change after insert to before insert to change the NEW values.

create or replace trigger totalclaimtrig2
before insert on userinfo
for each row
begin
    if :new.sgaji>'2323.41' and :new.power>1400 then
        :new.jumlah_claim := :new.jarak*0.7;
        :new.kelas:='A';
    elsif :new.sgaji>'2323.41' and :new.power between 1000 and 1400 then
        :new.jumlah_claim := :new.jarak*0.6;
        :new.kelas:='B';
    elsif :new.sgaji>'2323.41' and :new.power between 500 and 1000 then
        :new.jumlah_claim := :new.jarak*0.5;
        :new.kelas:='C';
    elsif :new.sgaji>'2323.41' and :new.power between 175 and 500  then
        :new.jumlah_claim := :new.jarak*0.45;
        :new.kelas:='D';
    elsif :new.sgaji>'2323.41' and :new.power<175 then
        :new.jumlah_claim := :new.jarak*0.4;
        :new.kelas:='E';
    end if;
end;