Home » Developer & Programmer » Forms » how to preven user from iserting duplicate records into tabular form
how to preven user from iserting duplicate records into tabular form [message #200755] Wed, 01 November 2006 04:01 Go to next message
qewani
Messages: 51
Registered: December 2005
Location: uaq
Member

hi

can any one tell me
how can i preven then user from typing duplicate records into tabular form? which trigger should i use?and how to do that?
Re: how to preven user from iserting duplicate records into tabular form [message #200757 is a reply to message #200755] Wed, 01 November 2006 04:03 Go to previous messageGo to next message
Cthulhu
Messages: 381
Registered: September 2006
Location: UK
Senior Member
Are you talking about a database table here or an Oracle Forms app or something else entirely ? Please be more specific and attempt to post to the correct forum.
Re: how to preven user from iserting duplicate records into tabular form [message #200972 is a reply to message #200757] Thu, 02 November 2006 01:49 Go to previous messageGo to next message
Littlefoot
Messages: 20901
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Basically, Form shouldn't have to do anything with it - it is a database whose job is to take care about duplicate records. This could done by creating appropriate primary/unique keys (or even indexes).
Re: how to preven user from iserting duplicate records into tabular form [message #201107 is a reply to message #200972] Thu, 02 November 2006 10:02 Go to previous messageGo to next message
yogen
Messages: 39
Registered: October 2006
Location: UK
Member
First thing you need to have primary or uniq key on your base table.
then one solution of your problem is that you can set DML set to 1 so that user can insert or update only one record at a time.

second you can use record groups and use when-validate-record trigger to insert the uniq key into record group and check newly inserted record against this record group.(i have never implemeted this but it should work)

and to make it more easy you can use a oracle table in place of record group .

e.g.

create a similar table like your base table.
in when-validate-record
just check
select count(*) into :v_count
from my_temp_table t1
where :blk.col1= t1.col1
....
all cols which are part of primary key....

and similar query on tha base table also

then if v_count is 0 then
insert into my_temp_table values(:blk.col1,blk.col2....)

something like this should fix your problem.

[Updated on: Thu, 02 November 2006 10:11]

Report message to a moderator

Re: how to preven user from iserting duplicate records into tabular form [message #201230 is a reply to message #200755] Fri, 03 November 2006 03:57 Go to previous messageGo to next message
qewani
Messages: 51
Registered: December 2005
Location: uaq
Member

ok guys ...
one more question
how can i restrict LOV selection so that the user can not choose the same selection more than once.

any idea?

[Updated on: Fri, 03 November 2006 03:57]

Report message to a moderator

Re: how to preven user from iserting duplicate records into tabular form [message #201248 is a reply to message #200755] Fri, 03 November 2006 04:55 Go to previous messageGo to next message
qewani
Messages: 51
Registered: December 2005
Location: uaq
Member

ok guys if i placed a KEY-NEXT-ITEM trigger on the field which i dont want it take duplicate records inserted by user, and if i put this code on it

if :edd_docu_code = PREVIOUSITEM  then message ('u already intered this before , so please inter a new record');
	else null;
	end if;


please help me !
Re: how to preven user from iserting duplicate records into tabular form [message #201437 is a reply to message #200755] Sat, 04 November 2006 04:01 Go to previous messageGo to next message
fahedakhter
Messages: 39
Registered: March 2005
Location: Pakistan
Member

To Restrict the Duplication Selection of same value use this technique.

1) Create a temporary table.Table Column depend on your scnerio.
2) Insert a Code in that table on Post-Text-Item Trigger.
3) Delete a code from that table on Pre-Text-Item Trigger.
4) Checking On When-Validate-Item,Lov Query.

Examples:

1) Create Global Temporary Table Dmy(Code Number) ;

2) Insert Into Dmy(Code) Values (:Block.Itemname); (POST-TEXT-ITEM)

3) Delete From Dmy Where Code = :Block.Itemname ; (PRE-TEXT-ITEM)

4) Select * From Tablename (LOV QUERY)
Where Code Not In ( Select Code From Dmy)

Regard's
Fahed
Re: how to preven user from iserting duplicate records into tabular form [message #201556 is a reply to message #201437] Sun, 05 November 2006 19:03 Go to previous messageGo to next message
djmartin
Messages: 10180
Registered: March 2005
Location: Canberra ACT Australia
Senior Member
Account Moderator
You can also use a dynamic record_group to hold the elements you wish to display in the LOV and in the When-Validate-Item trigger, if everything is okay, delete the entry that was just selected.

David
Re: how to preven user from iserting duplicate records into tabular form [message #202800 is a reply to message #201556] Sun, 12 November 2006 21:15 Go to previous message
djmartin
Messages: 10180
Registered: March 2005
Location: Canberra ACT Australia
Senior Member
Account Moderator
Also have a look at the possibility of making this 'special' field part of the table's primary key. Oracle Forms has builtin special processing for primary keys.

David
Previous Topic: FRM-41052
Next Topic: Can we view object (block, item) properties while debugging
Goto Forum:
  


Current Time: Sat Dec 10 16:27:00 CST 2016

Total time taken to generate the page: 0.21901 seconds