Home » Developer & Programmer » Forms » search for NULL fields (Oracle forms 6i)
search for NULL fields [message #541532] Wed, 01 February 2012 00:01 Go to next message
new_oracle2011
Messages: 174
Registered: March 2011
Location: Qatar
Senior Member
Is there any way to see items in the block having null in them? I want to figure out null field before inserting the data in the database table. At the moment I am having an error ORA 01400 which means that a NULL cannot be inserted into NOT NULL column. So, I want to create a procedure which will fire before insert trigger of the block and it will show me the names of items having null it them.
Procedure check_data(block_name in varchar2)
First_item varchar(20);
Current_item varchar(20);
Last_item varchar(20);
Begin
First_item := get_block_property(block_name, FIRST_ITEM);
Last_item := get_block_property(block_name, LAST_ITEM);
Current_item := first_item;
Loop
    If value_of(current_item) is null then
        Message(current_item); pause;
    End if;
Exit when current_item = last_item;
Current_item := the_item_after(current_item);
End loop;
End;

The problem is that I don't know the function to get the value inserted by user in the field so that I can compare it in IF condition. Please let me know if there is any function or do suggest be other way to do this.

Re: search for NULL fields [message #541533 is a reply to message #541532] Wed, 01 February 2012 00:08 Go to previous messageGo to next message
Littlefoot
Messages: 21818
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
The simplest way is to modify these items' property palette and set "Required" property to "Yes". Doing so, you won't even be able to leave the item empty.

Note that Forms is capable of doing that for you if you create a datablock using a Wizard.
Re: search for NULL fields [message #541868 is a reply to message #541533] Thu, 02 February 2012 22:33 Go to previous messageGo to next message
ollivier
Messages: 19
Registered: January 2012
Location: chihuahua
Junior Member
may you can use a block trigger "PRE-INSERT"
if ITEM_X is null then
note('ITEM_X CAN'T BE NULL !');
go_item('ITEM_X');
RAISE Form_Trigger_Failure;
end if;

Good Luck !
Re: search for NULL fields [message #541914 is a reply to message #541868] Fri, 03 February 2012 03:01 Go to previous message
cookiemonster
Messages: 13937
Registered: September 2008
Location: Rainy Manchester
Senior Member
1) Please read and follow How to use [code] tags and make your code easier to read?
2) The required property does the same job as your code without the code.
3) If you want to check it programatically when-validate-record is a better choice of trigger than pre-insert.
Previous Topic: unable to delete the record
Next Topic: Replace NULL with a different value during display (merged 2)
Goto Forum:
  


Current Time: Fri Aug 23 16:10:34 CDT 2024