Home » Developer & Programmer » Forms » calling validation in pre-insert trigger (oracle 10g)
calling validation in pre-insert trigger [message #482187] Wed, 10 November 2010 04:38 Go to next message
v1jay1
Messages: 5
Registered: October 2010
Location: INDIA
Junior Member
sir

my purpose is when PRE-INSERT trigger fires validation should be done like date format , primary key in table if validation is ok then a value of text box should be set to sequence no . else it should generate message


pls reply to v1jay1@yahoo.co.in

Re: calling validation in pre-insert trigger [message #482188 is a reply to message #482187] Wed, 10 November 2010 04:46 Go to previous messageGo to next message
cookiemonster
Messages: 13938
Registered: September 2008
Location: Rainy Manchester
Senior Member
What's stopping you?
Re: calling validation in pre-insert trigger [message #482294 is a reply to message #482188] Wed, 10 November 2010 22:43 Go to previous messageGo to next message
v1jay1
Messages: 5
Registered: October 2010
Location: INDIA
Junior Member
its throwing exception

PRE-INSERT trigger . Pls if you can advice code for it

requirement

Algo :-

PRE-Insert trigger

(
validate whether entries match database fields as primary key or date format

if validate success
textbox value = sequence no.

else
through message warning

)
waiting for your kind reply & cooperation
bye


Re: calling validation in pre-insert trigger [message #482334 is a reply to message #482294] Thu, 11 November 2010 01:42 Go to previous messageGo to next message
Littlefoot
Messages: 21818
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Could you post your code? Saying that "it is throwing an exception" doesn't mean much (as we don't know what exception it is).
Re: calling validation in pre-insert trigger [message #482378 is a reply to message #482334] Thu, 11 November 2010 03:51 Go to previous messageGo to next message
cookiemonster
Messages: 13938
Registered: September 2008
Location: Rainy Manchester
Senior Member
Also post the exact error message.
Re: calling validation in pre-insert trigger [message #482591 is a reply to message #482187] Sat, 13 November 2010 04:18 Go to previous messageGo to next message
v1jay1
Messages: 5
Registered: October 2010
Location: INDIA
Junior Member
my code and error mentioned

declare
a varchar2(10);
begin
message(' test pre ' );-- just to test message put
Validate('PV'); -- block name
if not Form_Success THEN
RAISE Form_Trigger_Failure;
CLEAR_RECORD;
Execute_Query ;
else

select refno.nextval into a from dual ; -- refno is sequence no.
:block7.ref_no :=to_char(a);
end if;
end; -- objective to put sequence no. to textbox if validation success

FRM -40735 PRE-INSERT trigger raised unhandled exception ORA-06502
Re: calling validation in pre-insert trigger [message #482601 is a reply to message #482591] Sat, 13 November 2010 09:38 Go to previous messageGo to next message
Littlefoot
Messages: 21818
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
A sequence means a number.
You are putting it into a VARCHAR2 variable. Oracle performs implicit conversion to do that, if possible. If a sequence number's length is greater than 10, then you can't put it into a variable whose max length is 10.

Here's an illustration:
SQL> create sequence seq_ora start with 100;

Sequence created.

SQL> declare
  2    a varchar2(1);
  3    b varchar2(10);
  4  begin
  5    select seq_ora.nextval into a from dual;
  6    b := to_char(a);
  7  end;
  8  /
declare
*
ERROR at line 1:
ORA-06502: PL/SQL: numeric or value error: character string buffer too small
ORA-06512: at line 5


SQL>
Re: calling validation in pre-insert trigger [message #482629 is a reply to message #482601] Sun, 14 November 2010 13:41 Go to previous messageGo to next message
cookiemonster
Messages: 13938
Registered: September 2008
Location: Rainy Manchester
Senior Member
Also this:
if not Form_Success THEN
RAISE Form_Trigger_Failure;
CLEAR_RECORD;
Execute_Query ;

Is completely wrong because:
1) If validation fails wouldn't you want the user to fix their mistakes instead of getting rid of what they've done so far?
2) RAISE Form_Trigger_Failure causes the trigger to stop executing at that point. So the following two commands can never ever run.
Re: calling validation in pre-insert trigger [message #482668 is a reply to message #482629] Mon, 15 November 2010 04:47 Go to previous messageGo to next message
v1jay1
Messages: 5
Registered: October 2010
Location: INDIA
Junior Member
thanks cookiemonster

but as you said

" 1) If validation fails wouldn't you want the user to fix their mistakes instead of getting rid of what they've done so far?
2) RAISE Form_Trigger_Failure causes the trigger to stop executing at that point. So the following two commands can never ever run "

so please tell alternative

my requirement is to check validation of a block in pre- insert trigger if its validate as per describe db fields and can insert record than i will generate sequence no.

else i will not

thanks Littlefoot
you gave me another thought too that i will avoid but
speak about my main problem pls

bye

Re: calling validation in pre-insert trigger [message #482671 is a reply to message #482668] Mon, 15 November 2010 05:00 Go to previous message
cookiemonster
Messages: 13938
Registered: September 2008
Location: Rainy Manchester
Senior Member
v1jay1 wrote on Mon, 15 November 2010 10:47
thanks cookiemonster

but as you said

" 1) If validation fails wouldn't you want the user to fix their mistakes instead of getting rid of what they've done so far?
2) RAISE Form_Trigger_Failure causes the trigger to stop executing at that point. So the following two commands can never ever run "

so please tell alternative


Raise an error. Do nothing else.

v1jay1 wrote on Mon, 15 November 2010 10:47

my requirement is to check validation of a block in pre- insert trigger if its validate as per describe db fields and can insert record than i will generate sequence no.


That requirement appears to be based on a misunderstanding about how forms works.

Whenever you try to insert or update a record in forms it will check if all the items and the record itself are marked as valid. If they aren't it'll automatically run any appropriate when-validate triggers. If they pass then the record is marked as valid and forms will proceed to the run the pre-insert/update trigger. If any fail you will get an error and processing will stop.

You do not do validation in pre-insert generally, you do it in the appropriate WHEN-VALIDATE trigger. You might want to generate the sequence no in pre-insert but nothing else.
Previous Topic: Uploading from Excel stopd when I open the file
Next Topic: form personalization
Goto Forum:
  


Current Time: Thu Sep 19 18:19:36 CDT 2024