This content has been marked as final. Show 2 replies
Your question seems to be unrelated to APEX, as there are no triggers in APEX. There are triggers in the database.
Also tables in a relational database don't have 'fields', they have columns.
Finally, from your description it appears you try to implement programmatically what every RDBMS has natively: a Foreign key.
If that is what you want to do you should create a FOREIGN KEY through SQL, on pf_po_infobox to pf_memberbanks.
Enforcing this programmatically is reallly a very very bad idea (tm) as your 'solution' won't scale.
Senior Oracle DBA
You can create a simple trigger to set the column values depending on other table column values, here is an example however I have not tested it -
Hope this helps.
CREATE OR REPLACE TRIGGER RTG_NAME BEFORE INSERT ON pf_po_inbox REFERENCING OLD AS OLD NEW AS NEW FOR EACH ROW DECLARE BANK_ID NUMBER; BEGIN SELECT BANK_ID INTO BANK_ID FROM pf_memberbanks WHERE BANK_ID = :NEW.DB_BANK_ID; IF BANK_ID IS NOT NULL THEN -- set the column value if the BANK_ID exists :NEW.PO_SB_MESSAGE := 'OK'; ELSE :NEW.PO_SB_MESSAGE := 'ERROR'; END IF; END;
Edited by: M Tajuddin on Mar 26, 2013 12:42 PM