Dynamic IF condition evaluation in Forms Environment [message #114957] |
Wed, 06 April 2005 10:30 |
v_joey
Messages: 3 Registered: April 2005 Location: INDIA
|
Junior Member |
|
|
Hi,
I'm using forms 9i. Let's say I have a Block in the form B1. It has two items I1 and I2.
I have a table called T1 that has a column say C1. The data in the only record in T1 is 'NAME_IN(''B1.I1'') = 1 OR NAME_IN(''B1.I2'') = 2'
In forms I need to execute the following at POST-QUERY trigger of the block:-
DECLARE
VAR1 VARCHAR2(1000);
BEGIN
SELECT C1
INTO VAR1
FROM T1;
IF (VAR1) THEN ==>> This is the problem
Set_Item_Instance_Property( 'B1.I1', CURRENT_RECORD, VISUAL_ATTRIBUTE,'VA1');
END IF;
END;
As you could see that the IF statement is wrong. But I get the condition (for IF condition) as a string value from some database table. Can anyone tell how to handle this problem.
Thanks & Regards,
Joey
|
|
|
Re: Dynamic IF condition evaluation in Forms Environment [message #114959 is a reply to message #114957] |
Wed, 06 April 2005 10:50 |
|
saadatahmad
Messages: 452 Registered: March 2005 Location: Germany/Paderborn
|
Senior Member |
|
|
What I understood, you'r requiring this type of functionality.
SQL> CREATE TABLE b1
2 (l1 NUMBER,
3 l2 NUMBER);
Table created.
SQL> CREATE TABLE t1
2 (c1 NUMBER);
Table created.
SQL> INSERT INTO t1
2 VALUES(1);
1 row created.
SQL> INSERT INTO b1
2 VALUES(1,2);
1 row created.
SQL> COMMIT;
Commit complete.
Now according to your form,
Post-Query Trigger on Block Level:
DECLARE
var1 NUMBER;
BEGIN
SELECT c1
INTO var1
FROM t1;
IF var1 = 1 THEN
Set_Item_Instance_Property( 'B1.l1', CURRENT_RECORD, VISUAL_ATTRIBUTE,'VA1');
ELSIF var1 = 2 THEN
Set_Item_Instance_Property( 'B1.l2', CURRENT_RECORD, VISUAL_ATTRIBUTE,'VA2');
END IF;
END;
You can see the result at run-time.
Change the value of c1 to 2 in t1 and the result will be reflected in the forms Run-Time.
Regards.
|
|
|
Re: Dynamic IF condition evaluation in Forms Environment [message #114963 is a reply to message #114959] |
Wed, 06 April 2005 11:01 |
v_joey
Messages: 3 Registered: April 2005 Location: INDIA
|
Junior Member |
|
|
No, Let me explain the question further.
The expression for the IF statement itself is stored in a string. For example
ANY_VARIABLE VARCHAR2(1000) := 'var1 = 1 ' ;
Now we cannot write as
IF ( ANY_VARIABLE ) THEN
Set_Item_Instance_Property( 'B1.l1', CURRENT_RECORD, VISUAL_ATTRIBUTE,'VA1');
ELSE
Set_Item_Instance_Property( 'B1.l2', CURRENT_RECORD, VISUAL_ATTRIBUTE,'VA2');
END IF;
How to handle this situation in which the expression itself is written in the ifstatement. If this would have been a PL/SQL expression only then EXECUTE IMMEDIATE would have worked. But please note that in the first example that I posted the expression will be made as
ANY_VARIABLE VARCHAR2(1000) := 'NAME_IN(''B1.I1'') = 1 OR NAME_IN(''B1.I2'') = 2';
The expression is referencing a object of the form also.
So, how to handle this situation where the expression itself is stored in a variable....
am I clear...??
Regards,
Joey
|
|
|
|
|
|
|
|
|
Re: Dynamic IF condition evaluation in Forms Environment [message #459621 is a reply to message #459276] |
Mon, 07 June 2010 08:32 |
gregor
Messages: 86 Registered: March 2010 Location: Germany
|
Member |
|
|
Hi v_joey,
I have attached two examples to evaluate the "CONDITION" saved in a database-column, " as -- 'var1 = 1 ' .
My solution for you is to substitute "var1" with the value you know. ( in post-query).
Gregor
PS: (If you would separate "var1 = 1", in tree database columns, it could give the way to work with name_in() in FORMS.
If your condition will be more and take a look at the theme "RulesManager and exprssion-Filters in the Database))
|
|
|