Tuesday, July 29, 2008

Simulate set_item_property('Block.item', intial_value, 'VALUE'); in Oracle Forms

Have you ever wanted to programmatically set and change the initial value of Oracle Form item at run time? Have you to do something like this in your Oracle Form?
set_item_property('Block.item', intial_value, 'VALUE')

and received the following error when you attempt to compile your form:
Error 201 at line .., column .. identifier 'INITIAL_VALUE' must be declared'


Well I have found a way to emulate having a dynamic value for the "Initial Value" property of an item.

1) Add a non-database item to your block. Call the item something like 'your_item_initial_value'

2) Set the "Copy Value from Item" property on your item to be your_block.your_item_initial_value

3) Whenever you want to change the initial value of your item just assign a value to the your_item_initial_value item.

4) Whenever you want to remove an initial value from your item just assign NULL to the your_item_initial_value item.

Note: I am using Oracle9iDS Release 2. Newer versions of iDS may permit you to programmatically change the initial value.

Mike

4 comments:

Patrick Wolf said...

Hi Michael,

if I remember correctly you can also just use the WHEN-CREATE-RECORD trigger to set a default value without changing record state.

Hope that helps
Patrick

Michael A. Rife said...

There you go. Using the WHEN-CREATE-RECORD trigger then I don't need the extra field. I will give it a try tomorrow.

Thanks,
Mike

Anonymous said...

Thanks a lot for this solution. The WHEN-CREATE-RECORD works fine for me ! (Forms Builder 10.1.2.2)

Rulas said...

I've trying to modify some properties in the WHEN_NEW_FORM_INSTANCE trigger using something like this

set_item_property('Block.Item',varchar_variable,'VALUE')

but the property name must be a number...do you know how to make something like this or where can I find the relation of this kind of enumerator..

ENABLED = 3
PROMPT_TEXT = 4

u_u

very nice post!