12 Replies Latest reply: Apr 8, 2013 1:23 PM by Andreas Weiden RSS

    Dynamic Set_Item_instance_property

    1001684
      Hi,

      I am trying to dynamically execute a set_item_instance_property, with a dynamic property.

      For instance:
      set_item_instance_property(w_field_name, current_record, w_property, w_value);

      With no success, since it does not accept the w_property value. Althought if I call my command by putting on te variable w_property 184(which means insert_allowed in oracle forms) it works.

      Does anyone knows where is the catalogue for each property or other solution to fix the problem?

      Thanks in advance

      Edited by: 998681 on 08/04/2013 05:21
        • 1. Re: Dynamic Set_Item_instance_property
          CraigB
          Does anyone knows where is the catalogue for each property or other solution to fix the problem?
          Did you check the Forms Help on the SET_ITEM_INSTANCE_PROPERTY built-in? Everything you need to know about the built-in is listed there. All of the supported properties for the built-in are listed there.
          set_item_instance_property(w_field_name, current_record, w_property, w_value);
          The Set_Item_Instance_Property() is expecting a literal for the PROPERTY parameter. As you are trying to use a variable that stores the parameter value, I don't believe this will work. You might be able to make this work using the NAME_IN built-in to get the value of the W_PROPERTY variable. For example:
          set_item_instance_property(w_field_name, current_record, NAME_IN('w_property'), w_value);
          Again, I'm not sure this will work, but it might.

          Craig...
          • 2. Re: Dynamic Set_Item_instance_property
            1001684
            I have already tried both (help and with the name_in) and it didn't work.

            Thanks anyway.
            • 3. Re: Dynamic Set_Item_instance_property
              Andreas Weiden
              I'm not quite sure whats the usecase for this? Could you explain a little more detailed?
              • 4. Re: Dynamic Set_Item_instance_property
                1001684
                What I am trying to do is: to configure in a table for a specific field it's property and value. For instance:

                Field | Property | Value
                Age | INSERT_ALLOWED | TRUE

                After that, I am trying to use a cursor to iterate over the previous list and then call set_item_instance_property for all those items.
                Althought, since the property is a number, I am not being able to use this cursor to dynamically configure the fields.

                If I configure the table as follow:

                Field | Property | Value
                Age | 184| 5

                This will work, since INSERT_ALLOWED means 184 and TRUE means 5 in oracle forms library.

                I am trying to understand if there is any optional way to do this, or if there is a catalogue with all these meanings for the properties.

                Thank you

                Edited by: 998681 on 08/04/2013 09:09

                Edited by: 998681 on 08/04/2013 09:13
                • 5. Re: Dynamic Set_Item_instance_property
                  Andreas Weiden
                  I understand your idea, but i would not recommend going that way. You just add a layer of complexity into your application. If you have the form-builder and need to change a properties value, use the forms-builder to do so.
                  • 6. Re: Dynamic Set_Item_instance_property
                    user346369
                    I, too, am not sure what the purpose of using dynamic properties or values -- I've never had any reason to use them.
                    ...Except for Property_True and Property_False once in a while.

                    But properties and their allowable values are just numbers, and can be found out this way:

                    From the online help, you can see from the description that the parameters for the command are most often just numeric constants:
                    <pre> SET_ITEM_INSTANCE_PROPERTY
                    (item_name VARCHAR2,
                    record_number NUMBER,
                    property NUMBER,
                    value NUMBER);</pre>

                    Coding this in a when-button-pressed trigger:

                    <pre>Declare
                    B_Bevel number := Border_bevel;
                    B_Bev_R number := Raised;
                    B_Bev_L number := Lowered;
                    B_Bev_P number := Plain;
                    --
                    Prop_t number := Property_True;
                    Prop_f number := Property_False;
                    V_attrib number := Visual_Attribute;
                    Begin
                    Message('Border_Bev='||B_Bevel||', Raised='||B_Bev_R
                    ||', Lowered='||B_Bev_L ||', Plain='||B_Bev_P
                    ||', Prop_True='||Prop_t
                    ||', Prop_False='||Prop_f
                    ||', Vis_Attrib='||V_attrib);
                    Message(' ',no_acknowledge);
                    End;</pre>

                    Returns this:
                    <pre> Border_Bev=1519, Raised=595, Lowered=596, Plain=537,
                    Prop_true=4, Prop_False=5, Vis_Attrib=1525</pre>

                    So you could code this and it would run:
                    <pre> Set_item_instance_property(My_Item,Rec_numb,1519,595);</pre>

                    That sets an item's Border_Bevel to Raised.
                    • 7. Re: Dynamic Set_Item_instance_property
                      user346369
                      This will work, since INSERT_ALLOWED means 184 and TRUE means 5 in oracle forms library.
                      So what doesn't work? It seems like you have all the tools you need.
                      • 8. Re: Dynamic Set_Item_instance_property
                        1001684
                        What about if Oracle changes the value of INSERT_ALLOWED from 184 to 69?

                        The purpose of this development is to make this mechanism dynamic enough, without the need to change the form.

                        Is there any way (not name_in, cause it doesn't work) to obtain the value of this variables (like ENABLED, INSERT_ALLOWED) having just the string with the name?

                        Thank you
                        • 9. Re: Dynamic Set_Item_instance_property
                          HamidHelal
                          998681 wrote:
                          What about if Oracle changes the value of INSERT_ALLOWED from 184 to 69?

                          The purpose of this development is to make this mechanism dynamic enough, without the need to change the form.

                          Is there any way (not name_in, cause it doesn't work) to obtain the value of this variables (like ENABLED, INSERT_ALLOWED) having just the string with the name?

                          Thank you
                          try an alternative. assign the variable value to a item or parameter and use this item or parameter in the built-in.
                          /*example */
                          Set_item_instance_property(My_Item,Rec_numb,:assign_item,595);
                          try
                          • 10. Re: Dynamic Set_Item_instance_property
                            1001684
                            It doesn't work.
                            • 11. Re: Dynamic Set_Item_instance_property
                              user346369
                              998681 wrote:
                              What about if Oracle changes the value of INSERT_ALLOWED from 184 to 69?
                              Oracle does NOT change Forms in that area. Why would they? ...Client/Server Forms 6 has been gone for ten years, and they haven't even updated the on-line help to identify features that no longer work in Web Forms.

                              But regardless, within your form, or within a PLL library, you could have a package spec or declared section of a procedure where you do as I have shown above:

                              <pre>Declare
                              B_Bevel number := Border_bevel;
                              B_Bev_R number := Raised;
                              B_Bev_L number := Lowered;
                              B_Bev_P number := Plain;
                              Ins_Allow number := Insert_allowed;
                              Enab number := Enabled;</pre>

                              Then you could use Ins_Allow as a variable anywhere you want. (This all seems redundant, though, to simply using the Insert_Allowed property, since Insert_Allowed is really just a numeric constant that the Forms pl/sql compiler knows about.)
                              The purpose of this development is to make this mechanism dynamic enough, without the need to change the form.

                              Is there any way (not name_in, cause it doesn't work) to obtain the value of this variables (like ENABLED, INSERT_ALLOWED) having just the string with the name?
                              Again, the above Declare section is about as good as it gets.

                              I just cannot grasp what you are achieving by trying to stuff all this into a table. I've written a lot of dynamic forms, and this issue has never come up.
                              • 12. Re: Dynamic Set_Item_instance_property
                                Andreas Weiden
                                The purpose of this development is to make this mechanism dynamic enough, without the need to change the form.
                                Dynamic enough for what?

                                The only chance i see is a CASE or IF-statement
                                IF property='INSERT_ALLOWED' THEN
                                  SET_ITEM_INSTANCE_PROPERTY(..,.., INSERT_ALLOWED, ..);
                                ELSIF ..