Home » Developer & Programmer » Forms » How to validate not null values for an item in when-validate-item through Program Unit
How to validate not null values for an item in when-validate-item through Program Unit [message #148223] Wed, 23 November 2005 03:22 Go to next message
sharan_it
Messages: 140
Registered: July 2005
Location: Chennai
Senior Member
I need to check whether item have null value while inserting,through when-validate-item.

I wrote a Program Unit named CHECK_NULL (To check whether item have null values while inserting)


PROCEDURE CHECK_NULL(ITEM CHAR) IS
ERROR_ITEM VARCHAR2(50);
CURRENT_ITEM_LABEL VARCHAR2(100);
BEGIN
IF ERROR_TYPE='FRM' AND ERROR_CODE='40202' THEN
ERROR_ITEM:=:SYSTEM.TRIGGER_ITEM;
CURRENT_ITEM_LABEL:=GET_ITEM_PROPERTY(ERROR_ITEM,PROMPT_TEXT);
MESSAGE(CURRENT_ITEM_LABEL||' '||'cannot be empty');
RAISE FORM_TRIGGER_FAILURE;
ELSE
MESSAGE(ERROR_TEXT);
END IF; 
END;



I kept Required Property as 'Yes' for PVIR_N_REQUESTER.

And am calling that Procedure in When-Validate-Item of a Item
PVIR_N_REQUESTER as

CHECK_NULL(:PVIR.PVIR_N_REQUESTER);


Both compiled sucessfully.

And if I give null value and press Tab, it gives error as
FRM-40202:Field must be entered.

That means this coding not working....Why its not working??

I attached that screenshot also..

Note: Earlier I kept Required Property as 'No' for PVIR_N_REQUESTER,then I changed it into 'Yes'.

If I kept it as 'No' it wont work??? Even I changed it as 'Yes' also is not giving expeced result.

Pls...experts tell me
  • Attachment: screen.doc
    (Size: 78.00KB, Downloaded 1302 times)
Re: How to validate not null values for an item in when-validate-item through Program Unit [message #148231 is a reply to message #148223] Wed, 23 November 2005 03:51 Go to previous messageGo to next message
Maaher
Messages: 7065
Registered: December 2001
Senior Member
It means that Forms is performing the validation. If you want your own validation, set the required property to 'N'.

Since I don't have Forms I fly blind here, but I think you can catch the Forms (FRM-40202)exception in your ON-ERROR trigger and place your coding there.

MHE
Re: How to validate not null values for an item in when-validate-item through Program Unit [message #148312 is a reply to message #148223] Wed, 23 November 2005 10:09 Go to previous messageGo to next message
bdrufner
Messages: 42
Registered: August 2005
Location: Home of the Mardi Gras, N...
Member
Hate to sound silly here, but wouldn't it be easier to just set a data constraint on the field in question on the database side to not allow NULL values?

Are you trying to save a trip to the database for validation or is there something else I am not getting?
Re: How to validate not null values for an item in when-validate-item through Program Unit [message #148387 is a reply to message #148223] Wed, 23 November 2005 22:12 Go to previous messageGo to next message
sharan_it
Messages: 140
Registered: July 2005
Location: Chennai
Senior Member
Am trying to validate null values for that field...and validation should be done through when-validation-item.It is database item.

I was thinking if i create a common Program Unit we can call that PU for all item on validation.Thats I tried..

But,not worked.
Re: How to validate not null values for an item in when-validate-item through Program Unit [message #148403 is a reply to message #148387] Thu, 24 November 2005 01:01 Go to previous message
Maaher
Messages: 7065
Registered: December 2001
Senior Member
sharan_it wrote on Thu, 24 November 2005 05:12

Am trying to validate null values for that field...and validation should be done through when-validation-item.
saravana, Forms performs the NOT NULL validation before the WHEN-VALIDATE-ITEM trigger fires, so I think you need to set the required property to FALSE.

In your WHEN-VALIDATE-ITEM trigger you can easiliy evaluate whether your field is NULL.

Have you tried putting the code in the ON-ERROR trigger?

MHE

[Updated on: Thu, 24 November 2005 01:01]

Report message to a moderator

Previous Topic: please help me am stuck
Next Topic: Calendar....
Goto Forum:
  


Current Time: Fri Sep 20 03:30:22 CDT 2024