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.

how to create a trigger on pl/sql when a function was used

User_7MMNGNov 22 2022

hello guy i'm trying to learn PLSQL and i'm stack on how to create a trigger on pl/sql when a function was used.
i'm tring to create to create a bank database so i create some table like account(numaccount, name, balance, num_card) num_card is a froeigen key card( num_card, max_delay, datecard)
so i make some functions like
-a function that alow to withdaral money from bank branch
-a function that alow to withdaral money using card
-a trigger avoid withdrawaling money when sold < ammount
now i want to create a trigger that avoid withdrawaling money when datecard is < of today date! this is my code:

CREATE OR REPLACE TRIGGER expirationcarte
BEFORE update ON COMPTE
for each row
DECLARE
v_date CARTE.DATEEXPIRATION%type;
BEGIN
select DATEEXPIRATION INTO v_date FROM CARTE C, COMPTE O WHERE C.NUMEROCOMPTE = O.NUMEROCOMPTE;
IF (v_date < to_char(SYSDATE,'MM-DD-YY') ) THEN
RAISE_APPLICATION_ERROR(-20012, 'la carte est expiré');
END IF;
END;
/

i want this trigger only work when the function that alow to withdaral money using card is runing!!

Comments
Post Details
Added on Nov 22 2022
4 comments
530 views