raise form_trigger_failure in WHEN-VALIDATE-RECORD still saves data [message #147684] |
Sat, 19 November 2005 02:38 |
adamjsawyer
Messages: 79 Registered: April 2005 Location: Perth, Western Australia ...
|
Member |
|
|
Hi, I have a WHEN-VALIDATE-RECORD trigger on one of my data blocks. When there is an problem with the data, I use RAISE FORM_TRIGGER_FAILURE. The error dialog appears, but it's still saving the data to the database!
Here is the code for the WHEN-VALIDATE-RECORD trigger:
-- WHEN-VALIDATE-RECORD Trigger for WTL_USERS Block in form MANAGE_ACCOUNTS
DECLARE
v_user_name VARCHAR2(10);
v_alert_button NUMBER;
BEGIN
-- Check if this is the ADMIN account
-- If it's a new account an error will occur - this is OK, nothing happens
SELECT user_name
INTO v_user_name
FROM wtl_users
WHERE user_id = :WTL_USERS.USER_ID;
-- If this is the ADMIN account, you cannot disable it
IF v_user_name = 'ADMIN' THEN
-- Ensure that the ADMIN account has not been disabled
IF :WTL_USERS.USER_ACTIVE = 'N' THEN
v_alert_button := SHOW_ALERT('ADMIN_ACTIVE_ALERT');
RAISE FORM_TRIGGER_FAILURE;
ELSIF :WTL_USERS.USER_NAME != 'ADMIN' THEN
v_alert_button := SHOW_ALERT('ADMIN_NAME_ALERT');
RAISE FORM_TRIGGER_FAILURE;
ELSIF :WTL_USERS.USER_ROLE != 'A' THEN
v_alert_button := SHOW_ALERT('ADMIN_ROLE_ALERT');
RAISE FORM_TRIGGER_FAILURE;
END IF;
END IF;
EXCEPTION
WHEN OTHERS THEN
NULL;
END;
What am I doing wrong?
Thanks
Adam
|
|
|
|
|
|
|
|