4 Replies Latest reply: Jan 16, 2014 5:33 AM by juliojgs RSS

    How to get forms constant values having constant name as char

    juliojgs

      Hi.

       

      As you may know, built-in parameters and values are full of numeric constants, i.e. DISPLAYED, WINDOW_STATE, PROPERTY_TRUE, MAXIMIZE, ...

       

      I'm programming a generic multiple SET_ITEM_PROPERTY that would read the property / value pairs from the database in a cursor and set the properties at the beginning of the form for various items.

       

      The problem is that, to ease readability, I'd like to store the properties and values in the database as the constant name, not the constant value, so I'm wondering if there is a way to extract that values if you've got the constant name as CHAR.

      Something like the Name_In built-in ... but for forms constants.

       

      A workaround would be creating another table with that constant/value pairs (would need the to get the list), but I'm not sure if it worths mantaining such estructure.

        • 1. Re: How to get forms constant values having constant name as char
          tony.g

          Hi Julio

           

          juliojgs wrote:

           

          The problem is that, to ease readability, I'd like to store the properties and values in the database as the constant name, not the constant value,

           

          I'm not sure I agree with this.

           

          Surely the database is the place to store encoded data, and the best way to store the data is as constant value.  Then you can write your metadata management frontend (e.g. written in forms!) to display the constant names for you.

           

          Isn't this how you would normally write a database application?

           

          rgds
          tony

          • 2. Re: How to get forms constant values having constant name as char
            Andreas Weiden

            As the constants are simply number value, you could do something like this

             

            CREATE TABLE PROPERTY_MAPPINGS (

              ID NUMBER,
              NAME VARCHAR2(80)

            )

             

            And in forms do something like

             

            INSERT INTO PROPERTY_MAPPINGS(ID, NAME) VALUES (INSERT_ALLOWED, 'INSERT_ALLOWED');

             

            Of course you have to do this for every property.

            • 3. Re: How to get forms constant values having constant name as char
              CraigB

              As I see it, the problem with storing this kind of metadata in the database is that for every lookup you perform on this metadata you have to go to the database to retrieve the values.  Depending on how often you will perform this type of comparison in your Forms application, it could cause your application to appear slow or actually slow it down.  Since these are Forms Constants, if you must have some type of table you can query against, I would opt more towards creating some type of an "In-Memory" collection that is subclassed in all of your Forms (via PL/SQL Library or Object Library) rather than have to hit the database each time your application needs to perform a comparison against this data.

               

              We do something similar to this in our application.  All of the code is stored in a PL/SQL Library (.pll) and the .pll is attached to all Forms.  We instantiate the "reference" collection in the Application Menu form and then it is available to all other forms called during that user session.

               

              Just my thoughts...

               

              Craig...

              • 4. Re: How to get forms constant values having constant name as char
                juliojgs

                Thanks CraigB, if there is not an easy way to access to the internal constant list (my "Name_In" like function), I'll have to go with your approach.

                 

                The procedure that sets the properties is already on a pll, so I could declare and fulfill an index by varchar2 collection, index by the constant name.

                 

                Are you implying that if I instantiate it in the pll in the application menu, and the called forms have the same pll attached, the collection is not flushed?