Home » Developer & Programmer » Forms » Dynamic IF condition evaluation in Forms Environment
Dynamic IF condition evaluation in Forms Environment [message #114957] Wed, 06 April 2005 10:30 Go to next message
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 Go to previous messageGo to next message
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 Go to previous messageGo to next message
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 #114973 is a reply to message #114963] Wed, 06 April 2005 11:36 Go to previous messageGo to next message
saadatahmad
Messages: 452
Registered: March 2005
Location: Germany/Paderborn
Senior Member

Well....you need a dynamic solution.....hmmmm.....let's see
Re: Dynamic IF condition evaluation in Forms Environment [message #115090 is a reply to message #114973] Thu, 07 April 2005 06:52 Go to previous messageGo to next message
Maaher
Messages: 7065
Registered: December 2001
Senior Member
Why don't you use 2 variables:
1 with the name.
1 with the content.

You can use the item_name and get its value via the name_in built-in.

Compare that with your content variable.

And via the find-item built-in to get the item_id, you can set the properties too.

MHE
Re: Dynamic IF condition evaluation in Forms Environment [message #115403 is a reply to message #114957] Mon, 11 April 2005 06:32 Go to previous messageGo to next message
subba lakshmi
Messages: 36
Registered: March 2005
Member
use a decode function in the select statment

i.e., select decode(namein,1,'one',2,'two') into varcharvariable from tablename;

now check if condition with varcharvariable=1 or varcharvariable=2

and check it out.

from
lakshmi

Re: Dynamic IF condition evaluation in Forms Environment [message #459258 is a reply to message #114963] Fri, 04 June 2010 03:25 Go to previous messageGo to next message
sassmine82
Messages: 19
Registered: June 2010
Junior Member
Hi v_joey,
Did you find a solution for your problem??
In fact, I need help to do that alse (putting expression for If statement in a table).

Could you help me please !!!

Thanks
Re: Dynamic IF condition evaluation in Forms Environment [message #459270 is a reply to message #459258] Fri, 04 June 2010 04:35 Go to previous messageGo to next message
v_joey
Messages: 3
Registered: April 2005
Location: INDIA
Junior Member
Yes... I found the solution.
I have implemented it also.
But it's way back in 2005.
I need some time to recall that.
Will get back.
Re: Dynamic IF condition evaluation in Forms Environment [message #459276 is a reply to message #459270] Fri, 04 June 2010 04:50 Go to previous messageGo to next message
sassmine82
Messages: 19
Registered: June 2010
Junior Member
ok thanks a lot.
don't forget me please Confused
Re: Dynamic IF condition evaluation in Forms Environment [message #459621 is a reply to message #459276] Mon, 07 June 2010 08:32 Go to previous message
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))
Previous Topic: Problem with List Item
Next Topic: Looking for Forms documentation
Goto Forum:
  


Current Time: Thu Sep 19 22:41:27 CDT 2024