PL/SQL in dynamic Action seems to return an incorrect value

Hi all

I am very new to the Apex and PL/SQL, so I don't know if I did something wrong here.

I have a form with a shuttle service (P4_ITEMS) and a field display only (P4_ORDER_TOTAL). I have a dynamic action put in place with the following PL/SQL:

declare
    tab apex_application_global.vc_arr2;
    total number := 0;
    itemPrice number;
begin
    tab := apex_util.string_to_table (:P4_ITEMS);
    for i in 1..tab.count loop
        select PRICE into itemPrice from PRODUCTS where PRODUCT_ID = tab(i);
        total := total + itemPrice;
    end loop;
    return total;
end;

If I understand correctly, tab must contain all the elements that are in the 'selected' part of the shuttle. I try to summarize the prices of selected items and return the set. Pretty simple, right?

Here is some info on the dynamic Action itself:

Event: Change; Selection type: Article (s); Article (s): P4_ITEMS (the shuttle)

The event (the PL/SQL function running) is also set to pull on the loading of the page. It is near the top not to expect results, so during the calculation, display field disappears briefly.

Here's the number: P4_ORDER_TOTAL updates only correctly when I first load the page. I enabled debugging but I changed my Shuttle, then checked out.

He recorded the P4_ORDER_TOTAL element. In this case, we will say it was 363.08. I added an item on the agenda and the PL/SQL is executed. The result, however, is 363.08, although he should have gone to the top. If I leave the page and then click its tab again, the order is always there, except that this time that it runs again the PL/SQL and it updates the P4_ORDER_TOTAL field to the correct value.

Can someone explain what is happening here? I can't understand why it isn't like I intend to work.

Feel free to ask me more questions if I'm not well explained.

Thanks in advance!

klanchman wrote:

I am very new to the Apex and PL/SQL, so I don't know if I did something wrong here.

Always include the following information in your question:

  • Full version of APEX
  • Complete version/edition/host operating system database
  • Server Web architecture (EPG, SST or APEX listener/operating system host and versions)
  • Browser (s) and version (s) used

For the layout and Visual set formatting issues. also include:

  • Theme
  • Type of zone
  • Models used

Here is some info on the dynamic Action itself:

Event: Change; Selection type: Article (s); Article (s): P4_ITEMS (the shuttle)

The event (the PL/SQL function running) is also set to pull on the loading of the page. It is near the top not to expect results, so during the calculation, display field disappears briefly.

Here's the number: P4_ORDER_TOTAL updates only correctly when I first load the page. I enabled debugging but I changed my Shuttle, then checked out.

He recorded the P4_ORDER_TOTAL element. In this case, we will say it was 363.08. I added an item on the agenda and the PL/SQL is executed. The result, however, is 363.08, although he should have gone to the top. If I leave the page and then click its tab again, the order is always there, except that this time that it runs again the PL/SQL and it updates the P4_ORDER_TOTAL field to the correct value.

Can someone explain what is happening here? I can't understand why it isn't like I intend to work.

At the time the dynamic action is executed, the value of P4_ITEMS is not available for the PL/SQL code in session state, it takes place only in the browser. Include P4_ITEMS in elements of Page to submit property the dynamics of the action so that the changed value is updated in the State of session before the PL/SQL code is executed.

Tags: Database

Similar Questions

  • Can a dynamic action of type 'alert' display a value of field without javascript?

    Hello

    can a dynamic action of type 'alert' display a value of field without javascript ( alert ( $x (P '200_OP').value)); ?

    What should I write in the 'text' section to display in the alert, the value of P200_OP for example?

    Gianpaolo cordially

    Hi gianpagi,

    gianpagi wrote:

    I know that with "run JavaScript Code" works. My question is about action as 'alert '.

    Dynamic action "Alert" is expected to this only the string to display in the alert. May not be able to access the current value set in a page element.

    Therefore, "Run the Code JavaScript" only works in this case where your can integrate the current values of the DOM html elements

    If you notice that da 'Alert' request 'Text' and 'Execute JavaScript Code' DA 'Code' request to be executed.

    Kind regards

    Kiran

  • How do dynamic actions using work to set the value in all browsers?

    I'm having a problem of incompatibility between browsers with dynamic actions to help to set the value.  Dynamic action works like a charm on Chrome but has no effect on IE or Firefox.  The code in oracle.apex.com and here are the credentials:

    Workspace: DDBA

    Username: [email protected]

    Password: redtruck12

    These codes is on page 3 and here are the details:

    There are two lists of report (Standard and special) and some reports require additional information provided in the lists of selection or text boxes.

    If the user selects a report select Standard requiring a list/text box, then the dynamic action sets the value of the special reports to NULL (and vice versa).

    Dynamic action is to prevent a simultaneous Standard reports and special selection.  To see how it works on Chrome, follow these steps:


    1. Run the Page 3
    2. Select the "Search report" option in the list Report Standard .  A text 'Search criteria' box
    3. Select the option 'Release report' in the list of special reports .  A selection list appears and disappears from the text box 'search criteria '.

    If you do the same on IE or Firefox, the text box does not disappear.

    Hi Edward,.

    Please check page 4 of your app, I made a copy of your page and made a few changes:

    I have set up an example of dynamic action 1 this hanles the report and special report selection list.

    Dynamic action games, select the value of the selection list and he accompanies in detail the report lists to null and then submits the page.

    For this I have deleted the page submit events to the time the report and special report select lists. Instead I handed them a HTML class. The dynamic action is triggered by a change of this category of html.

    When the trigger is the report selection list, select special report is set to null. Also underlying selection sub lists are set to null.

    When the trigger is the special report selection list, the selection of the report is set to null. Also underlying selection sub lists are set to null.

    The two end of the action with a "Send" page to manage the show and hide appropriate items. Note that there is a lag in time due to the submission of the page. As I have suggested, it would be treated better by a refresh of the region. On the other hand you depend on now submit for the continuation of the treatment of your page. With the help of an update of the region would require a work more javascript and cost more redisgn of your page. If you need IE8 support, additional javsascript likely to cause other unexpected behaviors. In other words, a page is maybe in your case probably better then an update of the region after all.

    I checked this page 4, Chrome, Firefox and IE (latest version) and I get the same behavior in all browsers.

    Kind regards

    Vincent

    http://vincentdeelen.blogspot.com

  • PDEElementGetBBox returns an incorrect value

    Hello

    I have developed a plugin that remove the object such as text, image, and path with respect to the coordinates of user input. In some cases, the value obtained by PDEElementGetBBox return the false value.

    Code I used

    If (PDEObjectGetType ((PDEObject) pdeElement) == kPDEPath)

    {

    PDEElementGetBBox (pdeElement, & bbox);

    float PathTop = ASFixedToFloat (bbox.top);

    float PathBottom = ASFixedToFloat (bbox.bottom);

    float PathLeft = ASFixedToFloat (bbox.left);

    float PathRight = ASFixedToFloat (bbox.right);

    If (the Condition is true)

    {

    PDEContentRemoveElem (pdeContent, j);

    }

    }


    Bbox return an incorrect value


    Is all that I'm missing

    Hmm. It seems that the method returns the BBox of the shape of XObject. This is the bounding box used to design the form elements, not the bounding box when she turned on the page scaling and offset. The documentation says that the BBox is returned in the 'user space '. I wonder, if you need to use PDElementGetMatrix and apply it to the BBox returned in this case - maybe anyway and you had the chance before - have you tried PDEImages?

  • activation / deactivation of field with dynamic action and apply the attribute 'required value.

    Hello

    Wanted to know how to force the 'required' attribute for the element off after that is "activated" by a dynamic action.

    For example, consider employee form.  I would like to disable the column of employment and salary.  As soon as the user enters the name of the employee, I will 'activate' JOB and SAL columns using "dynamic action".

    IMG-1.png

    IMG-2.png

    And above works fine.  Please note that both JOBS & SAL of columns 'NULL' according to the DB table.  My question is, how to comply with the condition of 'value' Yes, after allowing them.

    Another example would be, when the user selects 'Check' or 'Project', the 'no project' column will be activated.  Otherwise, "Project No." column is disabled (that is, the value is not required).  However, when turned on, I want to apply "value required" in this column.   How to get there?   (I use APEX 4.2.6)

    Thank you

    -Anand

    Why you do not create a function that returns a Boolean, validation of the page?

    You can do something like

    BEGIN

    IF: P5_ENAME IS NOT NULL THEN

    IF: P5_JOB IS NULL THEN

    Returns false;

    ON THE OTHER

    Returns true;

    END IF;

    END IF;

    END;

    You can change it to any desired column.

  • Dynamic action, you see is not the value of session

    Hi all

    I have a small question.

    My case: a person does not have more than 160 hours of work, but this should not be a restriction, but rather a warning.

    My solution:

    Create a dynamic action on a mouse button press which gives a confirmation and if you want to keep a page submit.

    That this dynamic action is a condition that a variable is greater than 160 hours.

    The problem with this method is that it does not work on the first insertion. The validation is not made that the item is null and no hours briefed.

    Option2:

    Create a hidden item to_much_hours.

    Create a dynamic action on hours of work point lose focus that defines the to_much_hours element hidden with the value true.

    Create a dynamic action on a mouse button press which gives a confirmation and if you want to keep a page submit.

    That this dynamic action has a condition that point to_much_hours = true.

    The problem with this method is that it only works when the page submitted. I mean, it's when I try to present awarded more than hours, can I still do it freely.

    But if I try to send more hours and another field is filled in wrong and a validation error is displayed. On the next try the popup of conformation appears.

    Can U help me?

    Raoul

    Hi Raoul,.

    Replace well confirmed by a piece of Javascript code.

    {if (($('#myitem').) (Val()>160)}

    var r = confirm ("hours high are you sure?");

    If (r is true)

    {

    Apex. Submit ('SAVE');

    }

    }

    on the other

    {

    Apex. Submit ('SAVE');

    }

    I'd say it's something like that, there might be errors because I couldn't test. Check the console for errors if it does not work or make an example to apex.oracle.com and we can help you more.

  • stageHeight returns an incorrect value

    Hi guys,.

    I am finally making the jump to AS3 and pressing on, so thanks for any help here (I still) search first.

    Writing a custom for my application Document class. I just set up a simple GUI with a header bar, toolbar and background using the drawing API so far. But in trying to position dynamically, I can't seem to get the correct size of the height of my step. It is too short of 100px!

    I write the code here in the hope, there's something stupid I do and you can point that out.
    Thank you.

    Jim.

    Well, I looked more and found that this is a stupid bug that does not (apparently) appear in the published swf file. I've never noticed this before because it's never happened to me before.

  • rowBytes returns an incorrect value

    Hello

    I am about to create an exporter for a compression format.

    I feel a strange situation where the value of ExportRecord-> rowBytes is giving a strange value that gives my code crash Photoshop.

    I process the image line by line and initially to create a buffer of size gStuff-> imageSize.h * gStuff - > imageSize.v * gStuff-> aircraft

    Now, I get the image data line-by-line, plan by plan, copy it into the buffer I created and move a pointer by rowBytes assuming its value would be the same as imageSize.h to copy the following line.

    This caused buffer overruns. After debugging using a simple 1000 x 1000 rgb image, I saw that returned 1008 rowBytes.

    For an image of 900 x 900 he returned 912.

    Why is this? It should be 1000 and 900 in these cases, I said to get only get a single plane and a single line.

    The doc says "rowBytes = the offset between the lines for the requested image data.", so these extra bytes whence? What value do have?

    If rowBytes is not the width of the image useful what?

    Thank you

    DiMI

    Scanlines are usually completed within limits of 16 bytes, so rowbytes reflecting.

  • Static LOV returns an incorrect value in a table

    I created a tabular form and when the form is created, I have to go in and edit the source of the region to include a decoding of one of the columns that I chose in the wizard. I use tables to create users for my application using a custom authentication scheme. I decode the password column to display either Set Password or reset the password. Therefore, it is necessary to change the code.

    ++ Code +++
    Select user_name, created_on, expires_on, user_id, $admin_user,
    decode (password, null, 'Set Password', 'Reset Password') PR
    of app_users
    where user_name! = "ADMIN".

    ++++++++++++++++++++++++++++++++++++++++++++++

    I have a static LOV:
    Yes; Y, no.; N

    I use this to indicate whether the user is an administrator or not

    I can fill data in the areas of text without a problem, but when I chose Yes for the admin_user column he always returns a value of "n" once I hit the Send button.
    I can then go and you change this value after registration, and it will then submit the admin_user as column "Y".

    Any ideas as to why its doing this and how to get it to stop?

    Is that occur when you add a new row of data?

    Any chance that there is a lack of "n" somewhere when you add new data?

    Jeff

  • Capabilities.screenResolutionY returning an incorrect value for the iPhone5

    Hello

    I'm trying to make gui adjustments based on the values returned by flash.system.Capabilities. However, when I test on the iPhone5 in portrait mode the values returned are screenResolutionX: '640' and screenResolutionY: '960'. I am compiling with air 3.5 in renderMode: "gpu" and put the swf metadata tp widthPercent: 100% and the heightPercent: 100%. I'm doing something wrong?

    Thank you

    CJ

    To get the right size, you will need to include a splash screen for the size of the iPhone 5, with the name of "[email protected]". This image would be 640 x 1136, and when he sees iOS, it knows that you want the iPhone 5 to use the entire screen.

  • PIC search returns an incorrect value

    I use advanced research VI for the tendency of a power spectrum amplitudes. Advanced VI research is not showing the correct amplitudes.  They are off by a little bit every time.  I watched the berries from the exit of the power spectrum, and I checked the cutting-edge research is get good input data but out something unexpected. I have advanced research for: 1) Single Max Peak, threshold = 0, start = 57.8 Hz, Stop = 59 Hz and 2) Single Max Peak, threshold = 0, Start = 61 Hz, Stop = 62.2 Hz. Or a poster of the correct value.  I'll post my code, but the file I open is a .dat so I can't post that.

    Research of spectrum VI made an adjustment to identify the peaks of the curve. Advanced search algorithm is described in the help:

    Details of the spectrum SVFA cutting-edge research

    The Spectrum Peak Search VI SVFA finds all of the peaks in the spectrum and makes an estimate amplitude/frequency or amplitude/order on each individual pic. The VI works on the ghosts of greatness and power.

    Usually, the spectrum is calculated based on an input with windows signal. The closed shape of any COS, such as Hanning, Hamming, Blackman-Harris window and so on, is known. The presence of three dominant bins indicates a local maximum on power spectrum. So, when the Spectrum Peak Search VI SVFA locates the three dominant bins, a curve maps algorithm the shape of window on three bins and believes that the true frequency and amplitude of this particular tone. The following illustration of the diagrams of the concept of the algorithm.

    ==================

    If you want the local maxima of the spectra, you can use the following code:

  • Dynamic action to execute PL/SQL that calls a JavaScript alert - does not

    Greetings,

    I'm stuck!  I use the Apex Version 4.2.2.  I have a requirement that, when the user fills Field1, I check the database to see if the value of field1 has already been used.  If it was used, I have to inform the user, but the user is allowed to reuse the value - that is to say, duplicates are allowed.  My thought is to use a dynamic action to check the onchange of value running pl/sql to check (via a function in the database) and if it returns true, use a javascript alert to inform my user value is used.  They can then close the alert and change (or not change) the duplicate value

    I did the following:

    1 wrote a PL/SQL function in my utility package in the database - we'll call it apps.my_utils.check_value_use (p_my_val in varchar2) return Boolean - it works.

    2. created a dynamic Action with the following properties for P1_FIELD1:

    Event: change

    Selection type: item (s)

    Product (s): P1_FIELD1

    Condition: is not null

    3. the dynamic Action has an action - real Action

    Action: Execute the PL/SQL Code

    Page items to submit: P1_FIELD1

    PL/SQL code:

    BEGIN

    IF apps.my_utils.check_value_use(:P1_FIELD1) = TRUE THEN

    HTP.p ("< script type =" text/javascript "> '");

    HTP.p ("alert (" this value is used ""); ")

    ');

    HTP.p ("< /script >" ");

    END IF;

    END;

    When I run the page and fill in Field1 with a value that I know is in use, I get the following error:

    Error: parsererror - SyntaxError: JSON.parse: unexpected character

    Help, please.  I already spent too much time on this apparently simple requirement.

    Thank you

    J.

    BEGIN

    IF apps.my_utils.check_value_use(:P1_FIELD1) = TRUE THEN

    HTP.p(' ');

    END IF;

    END;

    Avoid doing this. Try the following method:

    (1) create a dummy hidden element to store the result of your validation of PL/SQL. Lets call it P1_DA_ERR

    (2) in your PL/SQL block put this point hidden in the field "Page point back.

    (3) in your PL/SQL block placed the result of your validation in this element hidden as

    DECLARE
    l_err PLS_INTEGER := 0;
    BEGIN
    -- An example
    IF 1=1 THEN
    l_err := 0;
    ELSE
    l_err := 1;
    end if;
    :P1_DA_ERR := l_err;
    END;
    

    (4) add a true other "Run Javascript code" type action. The could should look like:

    if(parseFloat($v('P1_DA_ERR'))==1)
    {
    alert('Error occurred');
    }
    
  • Trigger a dynamic action of another dynamic action

    Hi - Maybe is there a better way to do it - but what I wonder how I can trigger something as part of the page to show or hide based on an event driven dynamic action...

    Let me explain:

    I have a page element which is a popup LOV. He selects a value (of course). It is ITEM1.
    I have a second element of the page. It is ITEM2.

    I have a dynamic action, based on the evolution of the value of ITEM1 - it searches of db (sql query/plsql function call) to extract a value related to this selected value of ITEM1 and dynamically sets the value of the ITEM2 with what is returned.

    So far so good.

    But I also have a third element of the page, ITEM3. What I want to do now is to show or hide ITEM3 based on the value of the ITEM2 (which has been defined by the dynamic action on changing ITEM1). So essentially, I need dynamic action on the evolution of the value of the ITEM2 so I can show/hide ITEM3.

    However, it seems that the dynamic action does not pull on the change of ITEM2, by the dynamic action of ITEM1.

    If you got this extreme grace, following! :-)
    Any thoughts on how to get there (even in completely other/better way)?

    Thank you
    David

    Hello David,.

    In the second dynamic action that's on fire when the value of the ITEM2 is changed, the scope "of the event ' to 'live '.

    Thank you
    Machaan

  • Consult the Page element values in the dialog box confirm dynamic action

    Hello

    I can return values to the Page item in the dialog box confirm dynamic action.

    I have a dynamic Action and I using the Action - confirm to display the confirmation message. I'm trying to refer point Page P1_EMP_NO say in the Confirmation box as shown below.

    Action - confirm
    Text - * & P1_EMP_NO.* "test123".

    When I have to run so that a dynamic action, confirmation shows only 'test123', the value for P1_EMP_NO is not displayed.

    My question is that we can refer such values as described above OR is there any other way to do it.

    ----
    Thank you
    Deepak

    Hi Deepak,

    You can see no elements in the confirm dialog box.
    You will need to write your own javascript and refer to elements such as dialog box

    $v('P1_EMP_NO') 
    

    Kind regards
    Kees Vlek
    -----
    Company: http://www.orcado.nl
    Blog: http://www.orcado.nl/blog/blogger/listings/69-kvlek
    Twitter: http://www.twitter.com/skier66
    If the answer to question please change replied and mark the appropriate post as correct / helpful.

  • Dynamic action fails using the null value on the list of selection change event

    I have a selection list that I created a dynamic action to which I added a value set to to clear the values of other controls on the form by assigning the value NULL.

    This doesn't seem to work, and I can't understand why it does not work.

    Event = change
    Selection type = Items
    Items = P4_MYSELECTLIST
    (no other condition for this action, I want it to reset for each change in the selection list).

    Fire on the Page Load = False (I only want what he reset values when I use this list of choices, not the page load).
    Set Type = static assignment
    Value = NULL
    Items = P4_ITEM1, P4_ITEM2, P4_ITEM3 (including 2 other lists of selection and control of text)
    Remove the Change = No event

    Xanas,

    If you set the values NULL and not the literal string "NULL" you must change your DA slightly. Modify your game to run JavaScript Code.

    Action = run the JavaScript Code
    Fire on the Page Load = False (I only want what he reset values when I use this list of choices, not the page load).
    Code = this.affectedElements.val ('');
    Items = P4_ITEM1, P4_ITEM2, P4_ITEM3 (including 2 other lists of selection and control of text)

    Edit:
    You can also change the real action to the following if you want to leave your DA as setpoint:

    Fire on the Page Load = False (I only want what he reset values when I use this list of choices, not the page load).
    Set Type = Expression JavaScript
    Value = "
    Items = P4_ITEM1, P4_ITEM2, P4_ITEM3 (including 2 other lists of selection and control of text)
    Remove the Change = No event

    Good luck
    Janet Tyson

    Published by: Tyson Janet on January 10, 2012 09:52

Maybe you are looking for