|
|
Re: how to scan duplicate records with out saving in to database [message #307487 is a reply to message #307401] |
Wed, 19 March 2008 00:31 |
thomasscaria
Messages: 21 Registered: July 2007 Location: Kuwait
|
Junior Member |
|
|
use this
PROCEDURE CHECK_DUPLICATE_REC(B_NAME IN CHAR, F_NAME1 IN CHAR) IS
BEGIN
DECLARE
NO_OF_RECS NUMBER;
FLD_VAL1 VARCHAR2(80);
TMP_VAL1 VARCHAR2(80);
CUR_BLK VARCHAR2(30);
CUR_FLD VARCHAR2(30);
NO_OPT VARCHAR2(1) := 'N';
DUPLICATE EXCEPTION;
BEGIN
CUR_BLK := NAME_IN('SYSTEM.CURRENT_BLOCK');
CUR_FLD := NAME_IN('SYSTEM.CURSOR_FIELD');
IF B_NAME = CUR_BLK THEN
LAST_RECORD;
ELSE
GO_BLOCK(B_NAME);
LAST_RECORD;
END IF;
NO_OF_RECS := NAME_IN('SYSTEM.CURSOR_RECORD');
<< OUTER >>
FOR X IN 1..NO_OF_RECS LOOP
GO_RECORD(X);
TMP_VAL1 := NULL;
TMP_VAL2 := NULL;
TMP_VAL3 := NULL;
TMP_VAL4 := NULL;
IF NAME_IN('SYSTEM.LAST_RECORD') <> 'TRUE' THEN
FLD_VAL1 := NAME_IN(F_NAME1);
<< INNER >>
FOR Y IN X+1..NO_OF_RECS LOOP
GO_RECORD(Y);
TMP_VAL1 := NAME_IN(F_NAME1);
IF TMP_VAL1 = FLD_VAL1 THEN
RAISE DUPLICATE; --- FIELD1 ONLY.
END IF;
END LOOP; ---- END INNER LOOP.
END IF;
END LOOP; ---- END OUTER LOOP.
GO_BLOCK(CUR_BLK);
GO_FIELD(CUR_FLD);
EXCEPTION
WHEN DUPLICATE THEN
MESSAGE('Error: Duplicate record ! ');
RAISE FORM_TRIGGER_FAILURE;
END;
END;
[Updated on: Wed, 19 March 2008 00:34] Report message to a moderator
|
|
|
Re: how to scan duplicate records with out saving in to database [message #307504 is a reply to message #307487] |
Wed, 19 March 2008 00:55 |
|
djmartin
Messages: 10181 Registered: March 2005 Location: Surges Bay TAS Australia
|
Senior Member Account Moderator |
|
|
@Thomas,
You need to read the OraFAQ Forum Guide as well. FORMAT your code and use 'code' tags!!
@OP
Looping is not the way to go because of validation issues. Use a dynamic 'record_group' and populate it with the keys that have been used. Then test against the database to see if anyone else has used it and against the 'record group' so see if the 'key' has been used in this form. Alternatively just have a unique index on the table and wait for the database to tell you that the entry has been used previously.
Search this forum for 'record group validate' for similar threads.
David
|
|
|