3 Replies Latest reply: Dec 3, 2013 6:59 PM by swesley_perth RSS

    Updating page at the beginning........

    Lecc23

      Hi,

       

      Mi application has a report as the first page after the user do a login page. This page (page1-Home) has a Date Picker item ( :P11_F_ACTIVIDAD ) that let the user pick the month/year for which they want to retrive data. Also, this item is configured to fetch the actual date (using sysdate) at the beginning by default. The idea with this page is that, the report shows up at the beginnig with data belonging to the actual month/year. Later, user could pick another month/year if they wish with a REFRESH button. To meet this requirenment, the following condition at the WHERE clause was added:

       

      WHERE

      .....

      AND substr(to_char(h.F_ACTIVIDAD,'DD MM YYYY'),4,7)=substr(to_char(to_date(nvl(:P11_F_ACTIVIDAD,sysdate),'DD MM YYYY'),'DD MM YYYY'),4,7)

       

      Since this modification, After the user logging (at very beginning login), the application goes to the page 1-Home showing "Data not found". After that, when a REFRESH command is excecuted manually, data is fetched normally without any problem after that.

      Look like when query is excecuted,  :P11_F_ACTIVIDAD oes not has the correct value. That why I add the nvl instruction with no successful.

      I appreciate you any comments about this issue. I ´m just learning APEX and I dont know lot of things about APEX.

       

      Thanks in advance,

       

      Luis

        • 1. Re: Updating page at the beginning........
          swesley_perth

          If I understand what you've done correctly, you may need to set the value of F11_F_ACTIVIDAD in a onLoad computation, not as what I suspect is a default value?

          It may also not like the to_date around the nvl.

           

          To simplify your query, (among other methods) you may be interesting in using trunc. eg:

          and trunc(h.f_actividad,'mm') = trunc(nvl(to_date(:F_actividad), sysdate),'mm')

          • 2. Re: Updating page at the beginning........
            Lecc23

            Thanks, Scott,

             

            You´re right......the page item :P11_F_ACTIVIDAD is configured with sysdate as default value and the original constrain was without the NVL:

             

            AND substr(to_char(h.F_ACTIVIDAD,'DD MM YYYY'),4,7)=substr(to_char(to_date(:P11_F_ACTIVIDAD,'DD MM YYYY'),'DD MM YYYY'),4,7)

             

            Now, in order to set the value of :P11_F_ACTIVIDAD in a onLoad computation.....you mean a "Calculation"?, where do I have to create the Onload Computation?....In page 1- Home or in page 12 (where item :P11_F_ACTIVIDAD and query exist)?.....Could you give me some tips to do this?

             

             

            Thanks one mere time,

             

            Luis

            • 3. Re: Updating page at the beginning........
              swesley_perth

              The reason you need a computation is to set session state, so when SQL is executed the database also knows what the browser knows (default value)

               

              If you create a compution page component (below items, above process on the component view) and set the computation point to "Before header" - you won't need the default value