Home » Developer & Programmer » Forms » Find Form property code
Find Form property code [message #207984] Thu, 07 December 2006 11:33 Go to next message
annagel
Messages: 220
Registered: April 2006
Senior Member
I am working on implementing a modification to our custom.pll library that makes form customizations easier. Basically setting up a table to store simple customizations to the objects on the form, no validation just simple stuff so a set item property would be one of the biggest uses I can see of this thing.

So my problem, I am going to have the users store all the stuff they want run in a database table, with arguments that should be passed, when doing this from the form the property values are defined globally for you and so calling is a simple

set_item_property('some.item', ALIGNMENT, 'ALIGNMENT_CENTER');


When I am storing these arguments in a table I have a couple of choices on how to store the property value.

1. I could say not my problem you are just going to have to find what number ALIGNMENT actually is and pass that into me and then if that changes and the form breaks too bad you fix it. Kind of mean and defeats the whole point of this being to make these changes easier, but I COULD do it.

2. Implement a big case statement where I map passed in varchar2 representations of the property to the property value from the form. This works and is what I will do if I have another choice, the big disadvantage here is just the typing, and typing and more typing.

3. ???? Here is what I hope someone has an idea on. If there any other way someone can think of to do this? It has to be simple for the user so something akin to just passing in the property at a varchar2, but I would very much like it to include a whole lot less work on my part than option 2.

Any ideas would be appreciated, typing this much is not something I am really looking forward to...

Thanks,
Andrew
Re: Find Form property code [message #208002 is a reply to message #207984] Thu, 07 December 2006 14:55 Go to previous messageGo to next message
annagel
Messages: 220
Registered: April 2006
Senior Member
Just to give a more basic explanation, I am looking for something like this :

DECLARE
   foo        VARCHAR2 (100) := '42';
   bar        VARCHAR2 (100);
   foo_name   VARCHAR2 (20)  := 'foo';
BEGIN
   EXECUTE IMMEDIATE 'select :' || foo_name || ' from dual'
                INTO bar;

   DBMS_OUTPUT.put_line ('foo->' || foo);
   DBMS_OUTPUT.put_line ('bar=>' || bar);
END;


which actually works, the end result in pretend world were this works is that :foo is bound to the local foo and the value '42' is placed in bar. The reality is that the execute immediate does not execute because I have not bound any value to :foo.

And I think this all may be moot anyway because I don't think execute immediate works in Forms 6i, thought I could be wrong on that, and I guess there is always dbms_sql which I have only spent a short amount of time looking at thus far.

Andrew
Re: Find Form property code [message #208021 is a reply to message #208002] Thu, 07 December 2006 19:20 Go to previous messageGo to next message
djmartin
Messages: 10180
Registered: March 2005
Location: Canberra ACT Australia
Senior Member
Account Moderator
I suggest using 'dbms_sql'. I have used it extensively and it is well documented and quite stable.

David
Re: Find Form property code [message #208033 is a reply to message #208021] Thu, 07 December 2006 22:15 Go to previous messageGo to next message
annagel
Messages: 220
Registered: April 2006
Senior Member
Do you know how I could use DBMS_SQL to accomplish this task? I have read the documentation and as far as I can tell the big hold up is scope, dbms_sql executes outside the scope of my local program and as a result does not have access to any of the variables defined there.

Re: Find Form property code [message #208039 is a reply to message #208033] Thu, 07 December 2006 23:12 Go to previous messageGo to next message
djmartin
Messages: 10180
Registered: March 2005
Location: Canberra ACT Australia
Senior Member
Account Moderator
You're right. I will work on another idea. I tried the following and am getting a good start as in they are both working.
declare
  v1 varchar2(61);
  v2 pls_integer;
  v3 pls_integer;
  v4 varchar2(61);
begin
--  set_item_property('djm_test.item_3',width,10);
  v1 := 'djm_test.item_3';
  v2 := width;
  v3 := 20;
  set_item_property(v1,v2,v3);
--
  v1 := 'djm_test.item_4';
  v2 := NEXT_NAVIGATION_ITEM;
  v4 := 'djm_test.item_3';
  set_item_property(v1,v2,v4);
--
  message('hello world'); pause;
end;

David
Re: Find Form property code [message #208160 is a reply to message #208039] Fri, 08 December 2006 07:00 Go to previous messageGo to next message
annagel
Messages: 220
Registered: April 2006
Senior Member
Thanks for the help, we have been down a similar looking road with execute immediate were basically we pass the variable into the statement. The problem with this is obviously that all we have is the variable name and not the variable itself and reconciling the two is something we just can't seem to get past.
Re: Find Form property code [message #208459 is a reply to message #208160] Mon, 11 December 2006 00:08 Go to previous messageGo to next message
djmartin
Messages: 10180
Registered: March 2005
Location: Canberra ACT Australia
Senior Member
Account Moderator
You say "The problem with this is obviously that all we have is the variable name and not the variable itself" but to which 'variable name' are you referring?

The code sample I posted handles all the form items okay. You can either use the Forms_API and work out the 'number' that corresponds to 'width' or 'NEXT_NAVIGATION_ITEM', or you can use an IF test to see which attribute is to be changed. I assume that you are only going to let your users change a few attributes.

To see how someone else has used the Forms_API look at FormsTool.

David
Re: Find Form property code [message #208583 is a reply to message #208459] Mon, 11 December 2006 07:32 Go to previous messageGo to next message
annagel
Messages: 220
Registered: April 2006
Senior Member
djmartin wrote on Mon, 11 December 2006 00:08
You say
The code sample I posted handles all the form items okay. You can either use the Forms_API and work out the 'number' that corresponds to 'width' or 'NEXT_NAVIGATION_ITEM', or you can use an IF test to see which attribute is to be changed. I assume that you are only going to let your users change a few attributes.


I actually wanted to be able to expose while not everything, pretty much everything in the set_item_property and a couple other procedures. The idea was to allow me to set this up without hard coding a translation from the strings they will have to a number via something like this:

function translate(param in varchar2) return number is
begin
case upper(param)
when when 'WIDTH' then
   return width;
when 'NEXT_NAVIGATION_ITEM' then
   return next_navigation_item;
end case;
end;


I am doubting that this is actually possible in PL/SQL because I have found no evidence thus far that it is.
What about name_in [message #208613 is a reply to message #208583] Mon, 11 December 2006 09:25 Go to previous messageGo to next message
annagel
Messages: 220
Registered: April 2006
Senior Member
This seems like a long shot, but I think it is my last best hope.

What about name_in?

something like

function get_prop(p_prop in varchar2) return number is
l_temp varchar2(240);
begin
l_temp := name_in(p_prop);
return to_number(l_temp);
end;


Seems like a good idea only it doesn't return a thing. Tried it with 'width' as my sample value and it raised an error. I can't think of anything I would prefix the built in value 'width' with, but maybe I am missing something, so just posting my last second idea to see if anyone can think of a prefix I might try.

Andrew
Re: What about name_in [message #208678 is a reply to message #208613] Mon, 11 December 2006 21:24 Go to previous message
djmartin
Messages: 10180
Registered: March 2005
Location: Canberra ACT Australia
Senior Member
Account Moderator
Have you looked at FormsTool?

David
Previous Topic: Urgent:ERROR :- FRM-40104:UNABLE TO RESOLVE REFRENCE TO ITEM
Next Topic: Where to validate a foreign key?
Goto Forum:
  


Current Time: Fri Dec 02 14:18:50 CST 2016

Total time taken to generate the page: 0.28843 seconds