prevent duplication on the form [message #662420] |
Mon, 01 May 2017 11:29 |
|
hassan08
Messages: 123 Registered: June 2011 Location: egypt
|
Senior Member |
|
|
i have tabular form and want to check values entering on then form before insert how can do this validation in trigger
when-validate-item
|
|
|
|
|
|
Re: prevent duplication on the form [message #662434 is a reply to message #662433] |
Tue, 02 May 2017 03:51 |
cookiemonster
Messages: 13962 Registered: September 2008 Location: Rainy Manchester
|
Senior Member |
|
|
The way I do that is to put post in the When-new-record-instance trigger. This tells forms to issue the appropriate insert/update to the DB but not commit it.
Then you can just write a select to check what you need in WVI.
|
|
|
Re: prevent duplication on the form [message #662482 is a reply to message #662434] |
Wed, 03 May 2017 09:20 |
|
shawaj
Messages: 89 Registered: January 2016
|
Member |
|
|
hello hassan08,
You can try like this code
declare
v_last number;
v_first number;
v_empno number;
v_current number;
begin
v_current := :system.cursor_record;
v_empno := :empno;
if :system.cursor_record > 1 then
first_record;
while ( :system.cursor_record < v_current) loop
if :empno = v_empno then
message('This is duplicate record');
go_record(v_current);
delete_record;
end if;
exit when :system.last_record='true';
next_record;
end loop;
else
go_record(v_current);
end if;
next_item;
exception when others then
null;
end;
*BlackSwan added {code} tags. Please do so yourself in the future.
[Updated on: Wed, 03 May 2017 12:55] by Moderator Report message to a moderator
|
|
|
|
|
|
|
|
Re: prevent duplication on the form [message #662498 is a reply to message #662493] |
Thu, 04 May 2017 02:54 |
cookiemonster
Messages: 13962 Registered: September 2008 Location: Rainy Manchester
|
Senior Member |
|
|
The only appropriate triggers are ones that don't allow restricted procedures - when-validate-item, when-validate-record, pre-insert and pre-update.
So your code just won't work. My initial suggestion will.
And if you really read the page on how to use code tags, why didn't you use them?
|
|
|
|
|
|
|
Re: prevent duplication on the form [message #662702 is a reply to message #662699] |
Wed, 10 May 2017 00:12 |
|
Littlefoot
Messages: 21823 Registered: June 2005 Location: Croatia, Europe
|
Senior Member Account Moderator |
|
|
Quote:
how can navigate to first value 1
But, why would you return to the first "1"? As far as I understood, you are now in row #4 whose value is "1" and you know that it is a duplicate. So delete it; why do you want to delete the "1" that resides in row #1?
The same goes for your next example.
|
|
|