This discussion is archived
6 Replies Latest reply: Feb 7, 2013 3:49 AM by bp21 RSS

Computation on text area while page rendering not working

bp21 Newbie
Currently Being Moderated
Hi,

I have a textarea P9_PRJ tied to table column. I have following computation for that:

<b>computation pt:</b> After header
<b>computation type:</b> pl sql expr
<b>computation:</b> substr(:P9_PRJ,instr(:P9_PRJ,'.')+1)
<b>computation condition:</b> instr(:P9_PRJ,'PARTICIPANT: ') > 0

Basically I want a substring of :P9_PRJ value to be displayed if it contains 'PARTICIPANT: ' substring in it.

It doesnt seem to work. Any help?

I am using :

Application Express 4.1.0.00.32
DB details - Oracle Database 11g Enterprise Edition Release 11.2.0.1.0
Web server architecture - APEX listener
Browser(s) and version(s) used - Chrome version 24/ Firefox version 3.6 and version 18

Thanks!
  • 1. Re: Computation on text area while page rendering not working
    fac586 Guru
    Currently Being Moderated
    bp21 wrote:

    I have a textarea P9_PRJ tied to table column. I have following computation for that:

    <b>computation pt:</b> After header
    <b>computation type:</b> pl sql expr
    <b>computation:</b> substr(:P9_PRJ,instr(:P9_PRJ,'.')+1)
    <b>computation condition:</b> instr(:P9_PRJ,'PARTICIPANT: ') > 0

    Basically I want a substring of :P9_PRJ value to be displayed if it contains 'PARTICIPANT: ' substring in it.

    It doesnt seem to work.
    This is not a problem description. How doesn't it seem to work? Is there an error message? Is no value computed? Is the wrong value computed? Does the computation run when it shouldn't according to the condition?

    What item is computed and how is it displayed?
  • 2. Re: Computation on text area while page rendering not working
    bp21 Newbie
    Currently Being Moderated
    There is no error message that gets displayed. I am unsure how to test if computation is executed.

    There is no effect on P9_PRJ value. I am expecting only a substring of it to be displayed.

    Item to be computed is P9_PRJ itself. Its a textarea getting value from database table column.


    Thanks!
  • 3. Re: Computation on text area while page rendering not working
    Denes Kubicek Oracle ACE Director
    Currently Being Moderated
    A computation is wrong in this place. You have a text area with a source database column. The computation will fire before the column source is fetched. It will throw no error. Create a process on load instead and run it after the fetch process - the same event but a higher sequence. In this process you can use the following code
    BEGIN
       IF INSTR (:p9_prj, 'PARTICIPANT: ') > 0
       THEN
          :p9_prj := SUBSTR (:p9_prj, INSTR (:p9_prj, '.') + 1);
       END IF;
    END;
    That should work for you.

    Denes Kubicek
    -------------------------------------------------------------------
    http://deneskubicek.blogspot.com/
    http://www.apress.com/9781430235125
    http://apex.oracle.com/pls/apex/f?p=31517:1
    http://www.amazon.de/Oracle-APEX-XE-Praxis/dp/3826655494
    -------------------------------------------------------------------
  • 4. Re: Computation on text area while page rendering not working
    fac586 Guru
    Currently Being Moderated
    bp21 wrote:
    There is no error message that gets displayed. I am unsure how to test if computation is executed.
    Use Debug mode to trace the rendering and processing of a page.
    There is no effect on P9_PRJ value. I am expecting only a substring of it to be displayed.
    The After Header computation is performed before the After Header ARF process fetches the column value. You can see the order of page events using Utilities > Page Events in the page definition.
    Item to be computed is P9_PRJ itself. Its a textarea getting value from database table column.
    Do you really want to do this? This will modify the P9_PRJ value fetched from the database. When the page is submitted this changed value will be saved, replacing the original column value.

    If this is really the required behaviour, database items can be modified when they are fetched using the Post Calculation Computation attribute in the item Source. To make this conditional you'll need to use a <tt>case</tt> expression:
    case 
      when instr(:P9_PRJ,'PARTICIPANT: ') > 0
      then
        substr(:P9_PRJ,instr(:P9_PRJ,'.')+1)
    end
  • 5. Re: Computation on text area while page rendering not working
    bp21 Newbie
    Currently Being Moderated
    Hi Denes,

    Thank you for your response. I created a process like you mentioned and I gave
    <b>Process point:</b> On Load - After Header

    It is neither giving any error nor I am getting substring displayed in place of actual value.

    Anything has to be changed?

    Thanks!
  • 6. Re: Computation on text area while page rendering not working
    bp21 Newbie
    Currently Being Moderated
    Hi fac586,

    Thanks for giving info about Debug Mode and Page Events. It iwas useful.

    I implemented <b> Post Calculation Computation </b>. Its working great!

    Thanks again for your quick responses!

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points