| Runtime Validation in Forms [message #396291] |
Mon, 06 April 2009 01:23  |
Nshan
Messages: 62 Registered: February 2009
|
Member |
|
|
I have a form with 3 col's
code , path, entry_key
in front end
when i try to add records it should perform following validation
code path entry_key
-------- ------- --------------
cm1 no csa
cm1?
it should throw one err msg like "selected record is already exist..."
ie. cm1 i hav chose already for 1st row....
my validation performs comparison between table n current value...
it should perform between 1st rec and 2nd record....
At run time it should check.
Not between the table n form values...
In the form itself it should check between various records..(lik 1st , 2nd records).
Can anyone help me???
Thanks in advance....
|
|
|
|
|
|
| Re: Runtime Validation in Forms [message #396341 is a reply to message #396314] |
Mon, 06 April 2009 03:55   |
Nshan
Messages: 62 Registered: February 2009
|
Member |
|
|
Hi,
I searched and i got one solution like,
->1st create record group with the columns with same data type as table. then start adding the value of the item into record group using add_group_column. Then to retrieve the value for the next time u need to use set_group_column.
I need some explanation. Or else based on my requirement can anyone suggest some solution??
|
|
|
|
| Re: Runtime Validation in Forms [message #396366 is a reply to message #396341] |
Mon, 06 April 2009 05:54   |
Nshan
Messages: 62 Registered: February 2009
|
Member |
|
|
DECLARE
a NUMBER(10):=0;
v_reason_code VARCHAR2(200);
v_flag VARCHAR2 (1) := 'N';
BEGIN
v_reason_code:=:DISPUTE_REASON_CODE_S.reason_code;
FIRST_RECORD;
WHILE (:SYSTEM.LAST_RECORD <> 'TRUE') AND (v_flag = 'N')
LOOP
IF v_reason_code=:DISPUTE_REASON_CODE_S.reason_code THEN
a:=a+1;
v_flag := 'Y';
ELSE
NEXT_RECORD;
END IF;
END LOOP;
IF a>0 THEN
FND_MESSAGE.SET_STRING('Multiple entries for reason code');
FND_MESSAGE.SHOW;
RAISE FORM_TRIGGER_FAILURE;
ELSE
NULL;
END IF;
END;
I have put this code Key-next-item trigger.
Can anybody help me in this.
This is not working.
|
|
|
|
| Re: Runtime Validation in Forms [message #396375 is a reply to message #396291] |
Mon, 06 April 2009 06:30   |
|
|
first_record is a restricted proceedure
u can not use it in the navigation triggers like
key next item
first write your code behind a buttons whn button pressed trigger to see if its working,
if you got your desired functionality, then try using it in the when-validate-item for that particular item, or in when validate record trigger (and make sure u check the record status if its in insert, changed)
[Updated on: Mon, 06 April 2009 06:37] Report message to a moderator
|
|
|
|
|
|
| Re: Runtime Validation in Forms [message #396380 is a reply to message #396291] |
Mon, 06 April 2009 06:57   |
cookiemonster
Messages: 13975 Registered: September 2008 Location: Rainy Manchester
|
Senior Member |
|
|
As I pointed out on your other thread, the problem with doing validation code in a key-next-item trigger is that users can bypass it.
They could use the mouse to navigate to another item for starters.
The simple solution is to post every record as it is entered.
This applies the records to the database but doesn't commit them.
Which means that the user will still be asked if they want to save changes when they exit the form and no other users will be able to see the records untill they are committed.
Having done that you can create a when-validate-item trigger that uses a cursor to see if the value the user has just entered already exists.
|
|
|
|
| Re: Runtime Validation in Forms [message #396391 is a reply to message #396380] |
Mon, 06 April 2009 07:34   |
Nshan
Messages: 62 Registered: February 2009
|
Member |
|
|
@cookiemonster
Since i am very new to Forms whatever you have explained i can understand. Can you tell me briefly by giving some examples.
Also i want to know about how by using cursor we can check existence.
|
|
|
|
| Re: Runtime Validation in Forms [message #396392 is a reply to message #396377] |
Mon, 06 April 2009 07:36   |
|
|
| Littlefoot wrote on Mon, 06 April 2009 16:44 | | itech wrote on Mon, 06 April 2009 13:30 | first_record is a restricted proceedure
u can not use it in the navigation triggers like
key next item
|
As far as I can tell, there's no problem in using FIRST_RECORD in the KEY-NEXT-ITEM trigger.
Perhaps you should revise your knowledge (or should I do it with mine)?
|
i think we both should revise, hehe...
pls do correct me if m wrong. we are all here to learn.
|
|
|
|
| Re: Runtime Validation in Forms [message #396393 is a reply to message #396291] |
Mon, 06 April 2009 07:40   |
|
|
|
also, an alternate approach is, if u have a database block having tabular records, then u can add a save button at the end of each record, so that the values are saved in database of each record, BUT user can still create / navigate in to next records without saving.
|
|
|
|
| Re: Runtime Validation in Forms [message #396397 is a reply to message #396291] |
Mon, 06 April 2009 07:52   |
cookiemonster
Messages: 13975 Registered: September 2008 Location: Rainy Manchester
|
Senior Member |
|
|
Cursors to check for existance is the most basic thing you can do with cursors.
Write a select to see if there's a record in the table with a value that matches the one the user is trying to enter in the form.
If the cursor finds anything raise an error.
Look up post in form builder help.
I suggest you call it from when-new-record-instance.
|
|
|
|
| Re: Runtime Validation in Forms [message #396400 is a reply to message #396397] |
Mon, 06 April 2009 08:06   |
Nshan
Messages: 62 Registered: February 2009
|
Member |
|
|
@ Cookiemonster
I am not comparing the value which i am entering with the values which is stored already in the database.
I should compare values whatever present in the form.
Checking between database values and current value from form thats also one of my requirement.
That i have done.
But run time duplication check i need to clarify.
I hope u have got my point.
|
|
|
|
| Re: Runtime Validation in Forms [message #396405 is a reply to message #396380] |
Mon, 06 April 2009 08:14  |
cookiemonster
Messages: 13975 Registered: September 2008 Location: Rainy Manchester
|
Senior Member |
|
|
I understood your point. You appear to have completely misunderstood mine.
Since you have to check against values already stored in the db you're going to need a cursor in WHEN-VALIDATE-ITEM to do that (or just rely on a unique constraint).
If you post every record as it is entered then that check will do everything.
|
|
|
|