Home » Developer & Programmer » Forms » find duplicates before commiting the records
find duplicates before commiting the records [message #78548] Fri, 01 March 2002 06:41 Go to next message
neel
Messages: 12
Registered: November 2001
Junior Member
I have a form based on the table which has a Primary key with a combination of (item_num, cust_num). The form is showing the cust_num and all the items for that customer. I have an add button on the form by which we can add more items to that customer, but now while adding it is not keeping track of the duplicate items entered. When i save the form, it gives an error saying 'Unable to Insert record'.
If the user has entered 20-25 items altogether and then gets the error, it will be difficult for him to find the duplicates manually. Is there any way i can check for the duplicates before saving. I also want the user to see the duplicate item numbers so they can do the necessary corrections.
Thanks in advance. Any help will be appreciated.
Re: find duplicates before commiting the records [message #78559 is a reply to message #78548] Sun, 03 March 2002 03:31 Go to previous messageGo to next message
sethu
Messages: 9
Registered: May 1999
Junior Member
Neel,
here is the code for that.

Declare
cursor chk_unique is
select 'x' from USER.TABLE where FIELD_NAME_TO_CHECK_UNIQUE_KEY=:BLOCK_NAME.ITEM;
tmp char(1);
Alert_Button Number;
A_id Alert;
begin
Open Chk_Unique;
Fetch Chk_Unique Into tmp;
Close Chk_Unique;
IF :System.RECORD_Status = 'INSERT' THEN
If Tmp is not null then
A_id := Find_Alert ('err');
Set_Alert_Property(a_id,Title,'Duplicate Entry');
Set_Alert_Property(a_id,Alert_Message_Text,'This is a duplicate entry. Re Enter');
Alert_Button :=Show_Alert(a_id);
Raise Form_Trigger_Failure;
End If;
END IF;
end;

You can check compound primary keys also by this way.

Also if you want to commit after insertion of each record AUTOMATICALLY, just create a WHEN-NEW-RECORD-INSTANCE at that block level and write this code
IF :SYSTEM.BLOCK_STATUS = 'CHANGED' THEN
COMMIT_FORM;
END IF;
Re: find duplicates before commiting the records [message #78579 is a reply to message #78548] Mon, 04 March 2002 05:12 Go to previous messageGo to next message
neel
Messages: 12
Registered: November 2001
Junior Member
I tried out the code given by u , but it is not working. Is there any other way of doing it.
Also, i want to show the duplicate items numbers along with the message.
Re: find duplicates before commiting the records [message #78586 is a reply to message #78548] Mon, 04 March 2002 18:10 Go to previous message
sethu
Messages: 9
Registered: May 1999
Junior Member
Neel,
send that form to me. Let me see that and do it.
Previous Topic: Re: why not generate .MMX file
Next Topic: Master Detail Delete
Goto Forum:
  


Current Time: Thu Mar 28 07:13:09 CDT 2024