Saturday, April 24, 2010

Enabling and disabling parameters dynamically. -2

Here is yet another post on same old topic - "Enabling and disabling parameters dynamically"
Well there is a slight change in requirement.
In my first post on this topic, user have a choice of selecting Yes or No, as a first parameter and based on this first parameter selection, we designed second parameter to behave accordingly.

But, what if there is no selection in first parameter.?
Or in other words, value for first parameter is NULL ?

Brief explanation about the requirement.
My concurrent program has got three parameters as below.
1. Receipt Batch Name
2. GL Date From
3. GL Date To.

Initially, when "Receipt Batch Name"  is NULL then GL Date parameters should be enable and ready to take values.

If a value is entered for "Receipt Batch Name", then GL Date parameters should be disabled.

Simple check to find first parameter as NULL or NOT NULL will not work. For example, consider the code below.
decode(:$FLEX$. XXAR_RECEIPT_BATCH_NAME,NULL,'IT IS NULL','IT IS NOT NULL')
-- this command is not enough.
You need to check for NULL values of any value set like below.
decode(nvl(:$FLEX$.XXAR_RECEIPT_BATCH_NAME:NULL,'X'),'X','Y',null) 


For complete solution, consider following screenshots.






Complete SQL Statement entered as default value is - 
select decode(nvl(:$FLEX$.XXAR_RECEIPT_BATCH_NAME:NULL,'X'),'X','Y',null) from dual











Enter following sql statment in place of  Table Name
(SELECT trunc(SYSDATE) - 1000 + LEVEL date_range FROM DUAL CONNECT BY LEVEL <= 1000) temp_tab