Home » Developer & Programmer » Forms » Validation problem in Non-dataBase block
Validation problem in Non-dataBase block [message #216566] Mon, 29 January 2007 07:47 Go to next message
shakti_goyal
Messages: 60
Registered: November 2006
Location: India
Member



Hello all,

I have a non database block and i want to insert the data in a table.....

So i pick the values in variables and issue a simple insert statement....... it is working fine.........

But when i want to validate any item with table data ,it is failed.......

I am using WHEN-VALIDATE-ITEM trigger and i want if user enter the such name which is already exits then it should not move to another field..

when i use GO_ITEM Built-In for the navigation purpose i m failed...

It give message that Illegile procedure in this trigger.....

Here is the code......


declare
x varchar2(2);
al_id alert;
err_txt varchar2(80);
al_button number;

begin

al_id := find_alert('ALERT');

select 1 into x from cust_master where first_name= :OPEN_ACCT.FNAME;

if x = '1' then

err_txt := 'Name is already Exists. Please Enter Another Name :-';
set_alert_property(al_id,alert_message_text,err_txt);

al_button := show_alert(al_id);


go_item('FNAME');
--clear_item;

end if;


end;





Re: Validation problem in Non-dataBase block [message #216609 is a reply to message #216566] Mon, 29 January 2007 12:26 Go to previous messageGo to next message
Littlefoot
Messages: 20897
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
A few objections to your code: 'x' is declared as a character variable, you are storing a number into it and still use a string in an IF statement. Why do you rely on implicit conversion?

Selecting '1' (or 1?) into 'x' could raise TOO-MANY-ROWS error if there is more than one record with the same value of 'cust_master.first_name' column (by the way, why shouldn't two or more customers have the same FIRST name?).

Do not use restricted procedures in WHEN-VALIDATE-ITEM trigger - as you've seen, it is an invalid choice. Also, it is not necessary to navigate to the same item - simply raise an error. Substitute GO_ITEM with RAISE FORM_TRIGGER_FAILURE.
Re: Validation problem in Non-dataBase block [message #216687 is a reply to message #216609] Mon, 29 January 2007 22:30 Go to previous messageGo to next message
shakti_goyal
Messages: 60
Registered: November 2006
Location: India
Member

thanks friend for ur reply..

But i m using a sequence to generate unique Account no.
when any user want to inset the record.....

So that in Insert option user enter all the info ...
I retrived account no from the table on the base of first name which is unique......


Do u another better solution.......

Regards
Shakti
Re: Validation problem in Non-dataBase block [message #216693 is a reply to message #216687] Mon, 29 January 2007 23:53 Go to previous messageGo to next message
Littlefoot
Messages: 20897
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
If I understood what you are saying, it is not uniqueness that prevents your code to work, but unallowable restricted procedure in the WHEN-VALIDATE-ITEM trigger.

I just said that SELECT 1 INTO ... *might* cause TOO-MANY-ROWS. If you are certain that it will not, even better!

So, what better solution are you talking about? Did you substitute GO_ITEM with RAISE? What happened?
Re: Validation problem in Non-dataBase block [message #216927 is a reply to message #216693] Tue, 30 January 2007 22:24 Go to previous messageGo to next message
shakti_goyal
Messages: 60
Registered: November 2006
Location: India
Member


My cursor is not going to specific field and it does not validate the field...

But when i write this code on WHEN-BUTTON-PRESSED it is working fine......

that means if i check the value when the user enter all info and then click on a push button then it is working fine....

It clears the block and go_item is working here......
Re: Validation problem in Non-dataBase block [message #217152 is a reply to message #216927] Wed, 31 January 2007 18:59 Go to previous message
djmartin
Messages: 10180
Registered: March 2005
Location: Canberra ACT Australia
Senior Member
Account Moderator
Please look at the thread containing http://www.orafaq.com/forum/m/208716/67467/?srch=unique+sequence#msg_208716

David
Previous Topic: Update in Pre-insert trigger
Next Topic: Possible to override Forms commit behaviour?
Goto Forum:
  


Current Time: Wed Dec 07 12:29:00 CST 2016

Total time taken to generate the page: 0.11162 seconds