I'm trying to assign a value to a variable based on an if statement to be used to insert into a table as part of a trigger
I'm trying to assign a value to a variable based if another variable that is calculated is great than zero.
CREATE OR REPLACE TRIGGER transactions_checking_trigger
AFTER INSERT OR UPDATE ON checking
FOR EACH ROW
DECLARE
account_type char(4);
account_num char(4);
trans_date date;
trans_amt number;
trans_type char(4);
trans_comments varchar(25);
BEGIN
account_type := 'CHEK';
trans_date := sysdate;
trans_amt := :new.balance-:old.balance;
if trans_amt > 0
trans_type := 'DEPT'
ELSE
trans_type := 'WDRW'
end if;
IF UPDATE THEN
INSERT INTO transactions (account_type, account_num, trans_date,
trans_amt, trans_type,trans_comments)
VALUES (account_type, :new.account_num,trans_date,trans_amt, trans_type,
new:trans_comments);
END IF;
END;
/
I expect the trigger to insert DEPT if trans_amt > 0 and WDRW if trans_amt < 0