Home » Developer & Programmer » Forms » Validating records...
Validating records... [message #78237] Fri, 01 February 2002 01:08 Go to next message
Umesh Sharma
Messages: 14
Registered: February 2000
Junior Member
Dear Oracle Friends

I have a master detail form in which detail table has composite key as primary key e.g. code1 + code2. Code1 is foreign key to master table. Now the problem is when I do the entry of code2 field I want to validate the duplicate entry without 'posting' the data to the database. Is is possible, if yes, how. I may mention that a user can add more than 1 record in detail block at a time and can also cancel some newly entered records.

Thanks

UMESH
Re: Validating records... [message #78239 is a reply to message #78237] Fri, 01 February 2002 12:48 Go to previous messageGo to next message
sokeh
Messages: 77
Registered: August 2000
Member
I have a few questions:
1, are you saying that duplicate records are
allowed in detail block but no master block?
2, you said you want to validate records in master(?) block before posting to the database, if your
your validation indicates that there are
duplicate records, what do you want to do then?
Re: Validating records... [message #78241 is a reply to message #78237] Sat, 02 February 2002 06:07 Go to previous message
Shilpa
Messages: 59
Registered: November 2001
Member
When validate item of code2 and code1 check whether the current records code1 + code2 combination exists in the block or not.

Sample code:

when validate item of code1 and code2 enter the following:

/* the following code assumes the row that was entered is the last row in the block*/

declare

checkc1 varchar2(10);
checkc2 varchar2(10);
fail varchar2(1) := 'N';

begin

/* check if code1 and code2 of the current row are not null */
if :detail.code1 is not null and :detail.code2 is not null then

/* store the current row values in checkc1 for code1 and checkc2 for code2 */
checkc1 := :detail.code1;
checkc2 := :detail.code2;

/* begin to check for duplicates */
go_block('detail');
first_record;
while (:system.last_record <> 'TRUE') and (fail = 'N') loop
if checkc1 = :detail.code1 and checkc2 = :detail.code2 then
fail := 'Y';
else
next_record;
end if;
end loop;

if fail = 'Y' then
message('DUPLICATE ENTRY');
end if;

end if;

end;

Hope this helps!!!
Previous Topic: Superimposing forms
Next Topic: Re: Validating records...
Goto Forum:
  


Current Time: Sat Apr 20 04:38:40 CDT 2024