How to find a duplicate record before commit? [message #314823] |
Thu, 17 April 2008 23:16 ![Go to next message Go to next message](/forum/theme/orafaq/images/down.png) |
rzkhan
Messages: 370 Registered: March 2005
|
Senior Member |
|
|
Hi..
I am using a form with three blocks. one of the block is based on table PRF. PRF table is as below
Name Null? Type
----------------------------------------------------- -------- ----------------
CARDNO NUMBER(5)
PREFERENCES NUMBER(1)
FACULTY CHAR(4)
The field PREFERENCES only accepts number from 0 to 6.
My requirements is:
1. Number 0 can be repeated but other Numbers(1.2.3.4.5.6)are not allowed to be repeated.
I think Primary or Unique key constraints will not work in this situation.so how can I control this programatically. Please help me. I am stucked here...
Thanks
Riaz
[MERGED by LF]
[Updated on: Sat, 19 April 2008 11:00] by Moderator Report message to a moderator
|
|
|
|
Re: Duplicate Record [message #314838 is a reply to message #314830] |
Fri, 18 April 2008 00:16 ![Go to previous message Go to previous message](/forum/theme/orafaq/images/up.png) ![Go to next message Go to next message](/forum/theme/orafaq/images/down.png) |
rzkhan
Messages: 370 Registered: March 2005
|
Senior Member |
|
|
It is restricted to CARDNO. i.e
ALLOWED:
cardno preferences
80001 0
80001 0
80001 2
80001 0
80002 1
80002 2
80002 3
80002 0
80002 0
80002 6
NOT ALLOWED:
cardno preferences
80001 3
80001 3
. But before COMMIT , how the WHEN-VALIDATE-ITEM can check for repeated value? If yes, Please how...
Thanks
Riaz
|
|
|
|
Re: Find duplicate before commit [message #315129 is a reply to message #314970] |
Sat, 19 April 2008 04:49 ![Go to previous message Go to previous message](/forum/theme/orafaq/images/up.png) ![Go to next message Go to next message](/forum/theme/orafaq/images/down.png) |
owais_baba
Messages: 289 Registered: March 2008 Location: MUSCAT
|
Senior Member |
|
|
hi rzkhan
you can control duplication like this
begin
select empno into :emp.empno from emp where empno=:emp.empno;
message('Record already exist');
message('Record already exist');
Raise form_trigger_failure;
Exception
when no_data_found then
null;
end;
dont feel hazitation for further question
owais
owaisuzair2007@yahoo.com
|
|
|
Re: Duplicate Record [message #315130 is a reply to message #314823] |
Sat, 19 April 2008 04:56 ![Go to previous message Go to previous message](/forum/theme/orafaq/images/up.png) ![Go to next message Go to next message](/forum/theme/orafaq/images/down.png) |
owais_baba
Messages: 289 Registered: March 2008 Location: MUSCAT
|
Senior Member |
|
|
you can do like this
declare
a number(1):=a;
f_name varchar2(35);
begin
f_name:=:form_name;
while :form_name is not null loop
if f_name=:form_name then
a:=a+1;
next_record;
end loop;
previous_record;
if a=2 then
message('already exist');
message('already exist');
else
next_record;
end if;
end;
dobt feel haziate for further question
owaisuzair2007@yahoo.com
owais
|
|
|
|
Re: Duplicate Record [message #315724 is a reply to message #315130] |
Tue, 22 April 2008 10:03 ![Go to previous message Go to previous message](/forum/theme/orafaq/images/up.png) ![Go to next message Go to next message](/forum/theme/orafaq/images/down.png) |
owais_baba
Messages: 289 Registered: March 2008 Location: MUSCAT
|
Senior Member |
|
|
hi rzkhan
its very simple this logic is restricting the duplicate records
in multiple records block like tabular fields
you can put this logic key-next-item or when-validate-record
both trigger you can use this logic will not check the database table records this will check multiple block only weither record we have selected in a multiple fields or not
thanks
owais
|
|
|
Re: Duplicate Record [message #315852 is a reply to message #315724] |
Wed, 23 April 2008 00:23 ![Go to previous message Go to previous message](/forum/theme/orafaq/images/up.png) ![Go to next message Go to next message](/forum/theme/orafaq/images/down.png) |
rzkhan
Messages: 370 Registered: March 2005
|
Senior Member |
|
|
Will the follwing work?
Should I replace the following my field name
:agdtet03facprf.preferences
it also shows ILLEGAL CONSTRUCT IN when-validate-record
|
|
|
|
Re: How to find a duplicate record before commit? [message #316196 is a reply to message #314823] |
Thu, 24 April 2008 04:02 ![Go to previous message Go to previous message](/forum/theme/orafaq/images/up.png) ![Go to next message Go to next message](/forum/theme/orafaq/images/down.png) |
*munnabhai*
Messages: 157 Registered: March 2008 Location: Riyadh
|
Senior Member |
|
|
Hi Owaise,
Where im wrong in this? it showing error ( Encountered the smbol Loop" 'when expecting one of the following if)
declare
a number(1):=a;
f_name varchar2(35);
begin
f_name:=:asset_master_new.arn_no;
while :asset_master_new.arn_no is not null loop
if f_name=:asset_master_new.arn_no then
a:=a+1;
next_record;
end loop;
previous_record;
if a=2 then
message('already exist');
message('already exist');
else
next_record;
end if;
end if;
end;
|
|
|
|
Re: How to find a duplicate record before commit? [message #316231 is a reply to message #316225] |
Thu, 24 April 2008 05:56 ![Go to previous message Go to previous message](/forum/theme/orafaq/images/up.png) ![Go to next message Go to next message](/forum/theme/orafaq/images/down.png) |
rzkhan
Messages: 370 Registered: March 2005
|
Senior Member |
|
|
When I enter the block, the whole FORM hangs and stops responding
declare
a number(1);
f_name varchar2(35);
begin
f_name:=:agdtet03facprf.preferences;
while :agdtet03facprf.preferences is not null
loop
if f_name=:agdtet03facprf.preferences then
a:=a+1;
next_record;
end if;
end loop;
previous_record;
if a=2 then
message('already exist');
message('already exist');
else
next_record;
end if;
end;
Riaz
|
|
|
|
Re: How to find a duplicate record before commit? [message #316366 is a reply to message #316225] |
Thu, 24 April 2008 16:25 ![Go to previous message Go to previous message](/forum/theme/orafaq/images/up.png) ![Go to next message Go to next message](/forum/theme/orafaq/images/down.png) |
owais_baba
Messages: 289 Registered: March 2008 Location: MUSCAT
|
Senior Member |
|
|
sorry dear again little mistake take last one this is correct sorry for cause iam very busy that's why this much hurry
declare
a number(1):=a;
f_name varchar2(35);
begin
f_name:=:asset_master_new.arn_no;
first_record;
while :asset_master_new.arn_no is not null loop
if f_name=:asset_master_new.arn_no then
a:=a+1;
end if; ---here end if will belong sorry for that
next_record;
end loop; --> END LOOP without END IF
previous_record;
if a=2 then
message('already exist');
message('already exist');
else
next_record;
end if;
end;
use this
owais
|
|
|
|
Re: How to find a duplicate record before commit? [message #316480 is a reply to message #316366] |
Fri, 25 April 2008 05:34 ![Go to previous message Go to previous message](/forum/theme/orafaq/images/up.png) ![Go to next message Go to next message](/forum/theme/orafaq/images/down.png) |
owais_baba
Messages: 289 Registered: March 2008 Location: MUSCAT
|
Senior Member |
|
|
hi dears
we are not here to teach you "ABCD" you have to use yours skills also i am attaching this .fmb file download this form and run and dont say this is not working before i cauld send you this form in my opinion try to explore your self i think you are in administration staff stop criticizing the people like that increase your skills 1st test you self we have been working here since 10 years in all over the world thanks
thanks
owais
|
|
|
Re: How to find a duplicate record before commit? [message #316486 is a reply to message #316480] |
Fri, 25 April 2008 06:11 ![Go to previous message Go to previous message](/forum/theme/orafaq/images/up.png) ![Go to next message Go to next message](/forum/theme/orafaq/images/down.png) |
![](/forum/images/custom_avatars/72104.gif) |
Littlefoot
Messages: 21823 Registered: June 2005 Location: Croatia, Europe
|
Senior Member Account Moderator |
|
|
I'm afraid you completely misunderstood what I was saying.
As far as I'm concerned, you can write your post upside-down if you wish, from right to left or even scrambled. It really doesn't matter, as long as you'll find someone who is going to read and (try to) understand that mess.
Your previous (and, as far as I can remember, ALL of your previous) post is a mess too. It may be clear to you at the moment you write this code. But, as you aren't doing it for your own amusement but to help other Forum member(s), try to understand that reading unformatted code may be extremely difficult; no indentation, which statement belongs to IF-THEN-ELSE, which one is in the loop and which is out ... as I've said - a complete mess.
Besides, try to write your messages using punctuation. It includes "full stop" (a "dot" (.)) sign at the end of each sentence. Your last message was written without it and, honestly, I'm not quite sure what you meant to say and - at the moment - I don't feel like deciphering another mess you produced.
As of criticizing you (or anyone else), you're out of luck - I was doing it, am doing it and will continue to do that any time I feel it should be done. Once again: if someone is illiterate, that's fine with me as long as it doesn't make this Forum look like a mess.
Finally, it's all up to you; if you continue to produce such messages, you'll find yourself ignored by some/many/most members as they will not want to spend their (free and precious) time to something hardly comprehensible.
I appreciate your contribution to the OraFAQ Forum, I really do; if only you could do that additional effort and make your posts easier to read and understand.
|
|
|
|
Re: How to find a duplicate record before commit? [message #318235 is a reply to message #314823] |
Tue, 06 May 2008 03:22 ![Go to previous message Go to previous message](/forum/theme/orafaq/images/up.png) ![Go to next message Go to next message](/forum/theme/orafaq/images/down.png) |
rzkhan
Messages: 370 Registered: March 2005
|
Senior Member |
|
|
I have the following code in key-next-item trigger.
declare
a number (1) := 0;
v_prf varchar2 (35);
i number;
begin
if :agdtet03facprf.preferences between 0 and 6 then
----- if preference is between 0 and 6 then do following (1)
----go to first record
v_prf := :agdtet03facprf.preferences;
first_record;
------------check for duplicate preference
while :agdtet03facprf.preferences is not null
loop
------------dont check for duplicate of 0
if v_prf = :agdtet03facprf.preferences then
if v_prf = 0 then
a := 0;
else
a := a + 1;
end if;
end if;
next_record;
end loop;
------message('out of loop. v_prf '||v_prf||'a '||a);
previous_record;
if a = 2 then
message ('Already Exists');
message ('Already Exists');
raise form_trigger_failure; ----------new line
else
if :system.last_record != 'TRUE' then
next_record;
else
go_item ('bsd.testcentre');
raise form_trigger_failure;
end if;
end if;
else ----- if preference is NOT between 0 and 6 then do following
message ('Invalid Preference');
message ('Invalid Preference');
raise form_trigger_failure;
end if; -- end (if)
end;
everything is working fine except when I query the records and enter the first item in agdtet03facprf block and press ENTER KEY the cursor moves directly to TESTCENTRE in another block.
Can any one help me to go to next record instead of going to another block.
sample screen shot is attached please.
Thanks
riaz
Upd mod: Fixed exceptionally crappy code and post formatting
-
Attachment: prf.JPG
(Size: 11.42KB, Downloaded 597 times)
[Updated on: Tue, 06 May 2008 19:51] by Moderator Report message to a moderator
|
|
|
|
|
|
|
|
|
|
|
|