3 Replies Latest reply: Apr 21, 2011 2:33 AM by 760421 RSS

    Best practice: Computations or Source

    760421
      Hi,


      Question about what's the best use.

      If you write a SQL query to get a value out of a database for a field on your page. What is the best way to do this.

      - By setting a computation (with the query) on that field
      - Or write te query in the source attribute of that field

      Both will have the same result.

      But what's the best practice?
        • 1. Re: Best practice: Computations or Source
          jariola
          Hi,

          It depends your need.
          You can do computation before regions and set value to session state.
          Then you can use value e.g. in report where clause when you run page.

          If you place query to item source, it do not set session state.

          regards,
          Jari
          • 2. Re: Best practice: Computations or Source
            Arie Geller
            Hello Davy,

            >> Both will have the same result.

            That’s not entirely correct.

            If you are using the SQL query in the item’s Source value or expression field, the retrieved value will not set Session State. Computation, on the other hand, will set Session State.

            Also, bear in mind that firing the Source content depends on how you set the Sourced Used field. If you set it to Only when … it will be fired only when the value of the item in session state is null.

            >> But what's the best practice?

            There isn’t any. It actually depends on what you need to achieve. If, for example, you need to set Session State, you only have one option.

            Regards,
            Arie.

            -------------------------------------------------------
            ♦ Please remember to mark appropriate posts as correct/helpful. For the long run, it will benefit us all.

            ♦ Author of Oracle Application Express 3.2 – The Essentials and More
            • 3. Re: Best practice: Computations or Source
              760421
              Thanks jarola & Arie Geller!