Home » Developer & Programmer » Forms » Trapped duplicate record but "Do you want to save changes?" message appears
Trapped duplicate record but "Do you want to save changes?" message appears [message #183262] Thu, 20 July 2006 03:21 Go to next message
cong
Messages: 25
Registered: June 2006
Junior Member
When user adds a record and it already exists, this trigger fires after I click on the Save button:

On-Error Trigger Code:

IF (lv_errcod = 40102) THEN
message('Please enter a value.');
ELSIF (lv_errcod = 40508) THEN
MESSAGE('Record already exists.');
ELSE
Message(lv_errtxt);
RAISE Form_Trigger_Failure;
END IF;

My problem is there's a Commit statement in the When-button-pressed trigger of the Save button so the message "Do you want to save changes?" appears. How do I trap this?

Thank you.
Re: Trapped duplicate record but "Do you want to save changes?" message appears [message #183367 is a reply to message #183262] Thu, 20 July 2006 09:53 Go to previous messageGo to next message
jowahl
Messages: 82
Registered: May 2006
Member
you could verify manually if the record exists:

in PRE-INSERT trigger of the block (fires at every COMMIT for every record) make your checks. if you find duplicate records, terminate the COMMIT built-in with RAISE FORM_TRIGGER_FAILURE.

hope this helps ...

Re: Trapped duplicate record but "Do you want to save changes?" message appears [message #183467 is a reply to message #183262] Fri, 21 July 2006 02:05 Go to previous messageGo to next message
cong
Messages: 25
Registered: June 2006
Junior Member
I used on-check-unique trigger but still the "Do you want to save changes?" message appears.

What happens is after pressing the Save button, commit statement is performed. Then, duplicate record is found so the message "Record already exists." appears. Followed by the "Do you want to save changes?" message. How can I trap this?

on-check-unique trigger:
DECLARE
CURSOR chk_unique IS
SELECT 'x'
FROM emp
WHERE emp_no = :blk.emp_no;
tmp VARCHAR2(1);
BEGIN
OPEN chk_unique;
FETCH chk_unique INTO tmp;
CLOSE chk_unique;
IF tmp IS NOT NULL THEN
Message('Employee no. already exists.');
RAISE Form_Trigger_Failure;
ELSIF form_fatal OR form_failure THEN
RAISE form_trigger_failure;
END IF;
END;
Re: Trapped duplicate record but "Do you want to save changes?" message appears [message #183477 is a reply to message #183467] Fri, 21 July 2006 02:28 Go to previous message
cong
Messages: 25
Registered: June 2006
Junior Member
I solved it already. Thanks!
Previous Topic: Need help
Next Topic: Transferring a text file from a windows PC to a Unix server
Goto Forum:
  


Current Time: Fri Sep 20 09:47:45 CDT 2024