Multi Row update using pl/sql anonymous block process

Does anyone have an example of multi row update using a pl/sql anonymous block process?
The reason I can not use the apex mru process is that the table in questions has a five field key.
My attempts have failed with a bad number.
Thanks,
Gary

Hi Gary,
can y<ou pls send the definition of thet table and the UPDATE sql.
It is a littel difficult like this.
We need more info.
BR,
Lutz
=;-)

Similar Messages

  • How come the item value does not come thru via PL/SQL anonymous block?

    Hi,
    It's a Form with 3 tables -
    1) ClinicianProfileTb (with about 40 columns, insert/update via DML),
    2) PeopleTb (with about 7 columns, insert/update via PL/SQL anonymous block) and
    3) ClinicianPracticeTb (with about 10 columns, insert/update via PL/SQL anonymous block) for after-submit-processes.
    So I have several After-Submit-Processes. For some reason, it appears that PeopleId which is supposed to come thru via the 2nd After-Submit-Process (ie: Insert/Update PeopleTb) does not do the way it's supposed to. And when I press "Create" button at the bottom, I got the following error msg:
    ORA-01400: cannot insert NULL into ("TEST_0712"."CLINICIANPRACTICETB"."PEOPLEID")
    I tried the "debug" mode (via edit page link), but to no avail. (I'm newbie, trying to learn and deliver at the same time :)).
    I uploaded the app to apex.oracle.com, if someone could kindly take a look and let me know what goes wrong, it'd be greatly appreciated.
    workspace: test_0712
    app: 43408 - TEST
    user: demo
    pswd: demoPswd
    Page#21 -> look at the After-Submit-Processes -> in "Insert/Update PeopleTb" it appears that PeopeId does not come thru; thus it cannot be updated to ClinicianProfileTb.PeopleId (allows null) -> and thus cannot be inserted into ClincianPracticeTb.PeopleId (which does NOT allow null). Basically my logic is that in order to create ANY row in ClinicianPracticeTb, BOTH PracticeId AND PeopleId must be present.
    Acutally I should have used the PeopeTb as DML (as the driving table) to enforce that PeopleId must be present in order to insert ClinicianProfileTb and ClinicianPracticeTb, but it'd be lots of codes to write to insert/update in ClinicianProfileTb (40 columns).
    In addition, does ApEx consider EVERY SINGLE after-submit-process are in ONE transaction for commit/rollback? It appears that it treats all PL/SQL anonymous blocks are in ONE transaction, while Automatic Row Processing (DML) is commited/rolled back on its own?
    Thanks much,
    Helen

    All blocks that do not commit in one of the ways I detailed (and which do not explicitly commit using a commit statement) are part of the transaction started with > the first DML statement issued in any of the page processes and continuing until a commit is issued.Say, there are the following processes in the After-Submit-Processes:
    1. Process1 -> Automatic Row Processing (DML)
    2. Process2 -> PL/SQL anonymous block
    3. Process3 -> PL/SQL anonymous block
    Based on what you describe, in the event that if there is no explicit "commit" issued in any of these processes, then an implicit "commit" will be issued at the end of Process3?
    Thanks, Scott.
    Doreen

  • Calling PL/SQL anonymous block from href in tabular report

    apex 2.2.
    I've got a tabular report where I've added some img columns with a href to call diff processes
    for example
    "<a href="f?p=&APP_ID.:22:&APP_SESSION.:BRANCH_TO_PAGE_ACCEPT|NEW_PROXY:NO:::22,ABCDEF ><img src="/i/asyl.gif" border="0" alt="Runprocess"></a>"
    When clicking on an image column in row x then I would like to run the process - no page submit.
    The pl/sql anonymous block process source calls package.storedproc(p1,p2) - two in parameters
    I'm struggling with the syntax and is wondering if there's a smarter way to achieve the same function
    Any ideas most welcome
    Thanks
    Peter

    &lta href="f?p=&APP_ID.:22:&APP_SESSION.:BRANCH_TO_PAGE_ACCEPT|NEW_PROXY:NO:::22,ABCDEFG" &gt&ltimg src="/i/asylogin.gif" border="0" alt="Process"&gt&lt/a&gtQuestion is how can you pass values from a row in a tabular report to the application process ?

  • Conditional Select List in a Report maintained using a Multi Row Update

    I have a SQL Report that is maintained with a "Multi Row Update" process. One of the columns needs to be ether a "Select List" based on a named LOV or just "Text" (Read Only) based on the value in the column. I have the UI working using a case statement and apex_items in me SQL but the Report Column is not marked "Edit" and the "Multi Row Update" process just ignores changes.
    Any help would be great!

    Just curious, why is the first parameter to in third TEXT_FROM_ITEM invocation NULL instead of 20? Also check your first parameter in your ELSE. Shouldn't it be a global number as well?
    Did you try adding a hidden item to your SELECT statement? Something like:
    (case
    when CSSN.KTTR_BILL_STAT_UID = KT_UTIL_PKG.get_kttr_uid_from_ref_val('SESSION_BILL_STAT','SESSION_BILL_STAT_1') then
    apex_item.select_list_from_lov(20,CSSN.KTTR_BILL_STAT_UID,'KTTR_SESSION_BILL_STAT_PRPR','','NO')
    when CSSN.KTTR_BILL_STAT_UID = KT_UTIL_PKG.get_kttr_uid_from_ref_val('SESSION_BILL_STAT','SESSION_BILL_STAT_2') then
    apex_item.select_list_from_lov(20,CSSN.KTTR_BILL_STAT_UID,'KTTR_SESSION_BILL_STAT_PRPR','','NO')
    when CSSN.KTTR_BILL_STAT_UID is null then
    apex_item.text_from_lov(20,'KTTR_SESSION_BILL_STAT')
    else
    apex_item.text_from_lov(20,CSSN.KTTR_BILL_STAT_UID,'KTTR_SESSION_BILL_STAT')
    end) as KTTR_BILL_STAT_DISP,
    apex_item.hidden(30,CSSN.KTTR_BILL_STAT_UID) MIRRORThen in either an Javascript onBlur event on KTTR_BILL_STAT_DISP or in a Page Process assign the value of KTTR_BILL_STAT_DISP to MIRROR.
    Mike

  • Using Create table command in a Pl/Sql Anonymous Block

    Hi,
    I need to create a table dynamically based on the table_name and column_names that a user wants. When I use a Pl/sql Anonymous block to do this, it complains. Any suggestions ?
    Thanks,
    Marisa

    Personally this sounds like a bad design to me. I would say under most "normal" circumstances, you should not be creating tables on the fly. Especially one where a user has control over what columns,datatypes to use. Let a developer or dba take care of that.

  • Autonomous Transactions usage in PL/SQL anonymous block coding

    Hi,
    I am trying to incorporate Autonomous Transaction for our work. I am using the tables provided below,
    CREATE TABLE T1
    F1 INTEGER,
    F2 INTEGER
    CREATE TABLE T2
    F1 INTEGER,
    F2 INTEGER
    insert into t1(f1, f2)
    values(20, 0)
    insert into t2(f1, f2)
    values(10, 0)
    Now, when I use the code snippet given below, it is working as expected.
    create or replace procedure p1 as
    PRAGMA AUTONOMOUS_TRANSACTION;
    begin
         update t2
         set f2 = 25
         where f1 = 10;
         commit;
    end;
    declare
    PRAGMA AUTONOMOUS_TRANSACTION;
    a integer;
    begin
         update t1
         set f2 = 15
         where f1 = 20;
         p1();
         rollback;
    end;
    Here, updation in t2 table is commited and t1 is rolled back, it is working as
    expected. I would like to achieve the same functionality through PL/SQL
    anonymous block coding, to do this, I use the following code snippet,
    declare
    PRAGMA AUTONOMOUS_TRANSACTION;
    a integer;
    begin
         update t1
         set f2 = 15
         where f1 = 20;
         begin
              update t2
              set f2 = 35
              where f1 = 10;
              commit;
         end;
         rollback;
    end;
    Here, data in both the tables are commited, how do I change it to work as I
    mentioned above like committing t2 alone, please help, thank you.
    Regards,
    Deva

    Can you explain what you're trying to accomplish from a business perspective? This doesn't look like a particularly appropriate way to use autonomous transactions, so you may be causing yourself problems down the line.
    That said, padders's solution does appear to work for me
    SCOTT @ nx102 Local> CREATE TABLE T1
      2  (
      3  F1 INTEGER,
      4  F2 INTEGER
      5  )
      6  /
    Table created.
    Elapsed: 00:00:01.03
    SCOTT @ nx102 Local>
    SCOTT @ nx102 Local>
    SCOTT @ nx102 Local> CREATE TABLE T2
      2  (
      3  F1 INTEGER,
      4  F2 INTEGER
      5  )
      6  /
    Table created.
    Elapsed: 00:00:00.00
    SCOTT @ nx102 Local>
    SCOTT @ nx102 Local> insert into t1(f1, f2)
      2  values(20, 0)
      3  /
    1 row created.
    Elapsed: 00:00:00.01
    SCOTT @ nx102 Local>
    SCOTT @ nx102 Local> insert into t2(f1, f2)
      2  values(10, 0)
      3  /
    1 row created.
    Elapsed: 00:00:00.01
    SCOTT @ nx102 Local> commit;
    Commit complete.
    Elapsed: 00:00:00.01
    SCOTT @ nx102 Local> DECLARE
      2     a INTEGER;
      3 
      4     PROCEDURE update_t2
      5     IS
      6        PRAGMA AUTONOMOUS_TRANSACTION;
      7     BEGIN
      8        UPDATE t2
      9           SET f2 = 35
    10         WHERE f1 = 10;
    11 
    12        COMMIT;
    13     END update_t2;
    14  BEGIN
    15     UPDATE t1
    16        SET f2 = 15
    17      WHERE f1 = 20;
    18    
    19     update_t2;
    20 
    21     ROLLBACK;
    22  END;
    23  /
    PL/SQL procedure successfully completed.
    Elapsed: 00:00:00.04Have you done something else that would cause a deadlock?
    Justin

  • Refresh pl/sql anonymous block via dynamic action?

    Greetings again to the community!
    Something I must be misunderstanding.
    I want to dynamically (ajax) update a select list depending on a page item. Now when you research for operations like this, you get some examples - but which mostly are older and... contain a lot of coding. So I am wondering if this is to be achieved in a simple way using dynamic action.
    I have created a testcase here where the html for a select list ist created in a pl/sql anonymous block like that:
    begin
    for i in (select EMPNO, ENAME from EMP
            where DEPTNO = :P50_DEP_NO or
                     :P50_DEP_NO is null)
          loop
      htp.p('<option value="' || i.EMPNO || '">' || i.ENAME || '</option>');
      end loop;
    end;Region header and footer contain the tags for <select id="selEmps"> ... </select>.
    When you press [Btn Update Sel], a dynamic action is triggered, that submits :P50_DEP_NO, then refreshes the region with the pl/sql code, so that, after you have enteres another value in :P50_DEP_NO, the select list then shows the employees of that department. Thats the plan, but
    Its not working! Can anyone tell me, what I have overlooked here, please?
    Thank you and good night for now,
    tobi

    Hi Marko,
    thanks for your hint. I have already tought about that, but im not sure if this is the solution of this particular situation, because the list really should be generated html-code for formating reasons with jQuery UI and further processing. But I have not worked so much with cascading LOVs, so I really should look into it further.
    If I dont find a solution there, I'll get back here.
    Thanks and so long,
    tobi

  • Multiple Users - Tabular Forms - Multi Row Update.....

    Greetings All,
    Any comments, assistance, links, or even answers on the following situation would be much appreciated....
    I have a Application Express 4.0 (Could upgrade to 4.1 if it would help this issue)
    I have a wizard generated tabular form on a table, the form will show up to 600 records (rows) on a page.
    Part 1:
    The situation:
    User 1: Opens the form and brings up latest data set.
    User 2: Opens the form and brings up the latest data set.
    User 1: Changes data for record 1
    User 1: Hits submit. The data is saved.
    User 2: Changes data for record 1
    User 2: Changes data for record 2
    User 2: Hits submit. The following error is produced:
    Error in mru internal routine: ORA-20001: Error in MRU: row= 1, ORA-20001: ORA-20001: Current version of data in database has changed since user initiated update process. current checksum = "3EE15D666E9DBDC59D34CE4CFB3950C0", item checksum = "922DA12AE1E3D8856695745C4D2830D2"., update "<Removed> Error Unable to process update.
    When this error occurs no updates get made to the table.
    I understand that row 1 can not be updated, however I would like row 2 (and all other rows where there is no conflict) to be updated. I would then like to be able to highlight in the form the rows that failed to update (And reload the data in them from the DB).
    Is this something I can achieve using my own MRU procedure, or in another way?
    Can anyone point me to a good example, tutorial or book showing how to do this.
    Thanks!

    Thanks for the comments guys.
    I have solved my issue in two different ways. Way one was not so clever, but worked, involving writing my own process for handling multi-row updates and would allow a user to fill in data for multiple rows (say 10) and have only the row with changed data rejected. V2 takes a very different approach, it uses Javascript, AJAX and the DOM model of the form to check when data is changed / updated by the user. Essentially, when a user enters an updateable form element, a AJAX request checks if the data has been changed. If it has, the value in the form is updated, and the color changed to blue to alert the user. When the user updates the data item, and AJAX request posts the new value to the database, where it is inserted. I had to build a bit of a framework to make this useable, and have to use dynamic sql in the database packages, but it work really well for what my users need! There are limitations (Currently it only supports date fields, text fields and drop down lists) but it works for me. It also involves traffic back and forth with the server each time a user moves the focus to a new form element, but it is a very light request and the work to do the select / updates in oracle is all based on a primary ke, so is ver quick.
    Solution 1: (Would need to be made much more elegant):
    1: Create a new text Item called P5_MESSAGE (To display error / success messages)
    2: Create a new process:
    DECLARE
    l_cks wwv_flow_global.vc_arr2;
    j pls_integer := 1;
    vUpdatedCount number := 0;
    vErrorCount number:=0;
    vMessage varchar2(4000):='';
    BEGIN
    select wwv_flow_item.md5(firstname,lastname,age) cks
    BULK COLLECT INTO
    l_cks
    from VA_TEST1 ;
    for i in 1..l_cks.count
    loop
    if htmldb_application.g_fcs(i) != l_cks(i) then
    -- Log error
    vErrorCount:=vErrorCount+1;
    vMessage:=vMessage||'Could not update row with ID:' || htmldb_application.g_f01(i) || '. This data has been updated by another user since you retrieved the data.<br>';
    else
    -- Do insert
    vUpdatedCount:=vUpdatedCount+1;
    update VA_TEST1
    set
    FIRSTNAME = replace(htmldb_application.g_f02(i),'%'||'null%',NULL)
    ,LASTNAME = replace(htmldb_application.g_f03(i),'%'||'null%',NULL)
    ,AGE = replace(htmldb_application.g_f04(i),'%'||'null%',NULL)
    where ID = htmldb_application.g_f01(i);
    end if;
    end loop;
    :P5_MESSAGE := vMessage;
    end;
    Note, this currently updates every row, even if the data is unchanged, this could be fixed by comparing the checksum of the data to be inserted with the checksum of the data in the table, if the same then no need to insert.
    Solution 2:
    Too complex to explain in detail here, if you need to implement this then let me know.

  • About Multi Row Update...

    APEX support Multi Row Update, but it is only support have two or fewer columns making up the primary key. now i want to use 3 columns as primary key to update datas, i how to implement it in APEX? thanks
    · Table Owner: The schema name for the owner of the table.
    · Table Name: Enter the table name or view. MRD’s and MRU’s can only dynamically build SQL statements for a single table or view.
    · Primary Key Column: This is the first column of the primary key for the table. It is used for building the WHERE clause for the dynamic statement.
    · Second Key Column: This is the column name for the second database column making up the primary key for the table. The MRU and MRD processes can only be used for tables that have two or fewer columns making up the primary key.
    Edited by: user8016603 on 2011-3-14 上午1:51

    check {message:id=9369070}

  • Reference value of an SQLPLUS variable in a PL/SQL anonymous block

    All,
    Is there a way of referencing an SQLPLUS variable within a PL/SQL anonymous block. See my example below........
    sqlplus -s /@${L_DB_SID} <<-ENDOFSQL >> ${L_LOGFILE}
    SET FEEDBACK OFF
    SET PAGES 0
    SET SERVEROUTPUT ON
    WHENEVER SQLERROR EXIT SQL.SQLCODE
    WHENEVER OSERROR EXIT 2
    VARIABLE l_ret_sts NUMBER;
    VARIABLE l_ret_msg VARCHAR2(300);
    exec sh_plsql_owner.sh\$secure_batch.p\$set_role(p_ret_sts => :l_ret_sts);
    begin
    if :l_ret_sts > 0 then
    dbms_output.put_line('l_ret_sts:'||:l_ret_sts||':SECURITY');
    else
    ${L_PLSQL_PROG}(p_ret_type => 0, p_ret_sts => :l_ret_sts, p_ret_msg => :l_ret_msg);
    dbms_output.put_line('l_ret_sts:'||NVL(:l_ret_sts,0));
    dbms_output.put_line('l_ret_msg:'||:l_ret_msg);
    end if;
    end;
    exit
    ENDOFSQL
    I need to be able to reference :l_ret_sts in the begin block using the if statement "if :l_ret_sts > 0 then"
    :l_ret_sts is populated in a procedure call beforehand.
    However it seems as though the begin block cannot reference the value returned to :l_ret_sts.
    Any ideas.
    Ian.

    Managed to solve this. I put my call to the package that the role enables via dynamic sql....
    sqlplus -s /@${L_DB_SID} <<-ENDOFSQL >> ${L_LOGFILE}
    SET FEEDBACK OFF
    SET PAGES 0
    SET SERVEROUTPUT ON
    WHENEVER SQLERROR EXIT SQL.SQLCODE
    WHENEVER OSERROR EXIT 2
    VARIABLE l_ret_sts NUMBER;
    VARIABLE l_ret_msg VARCHAR2(300);
    exec dbms_application_info.set_client_info('CONTROL-M');
    exec sh_plsql_owner.sh\$secure_batch.p\$set_role(p_ret_sts => :l_ret_sts);
    declare
    v_text varchar2(500);
    begin
    if :l_ret_sts > 0 then
    dbms_output.put_line('l_ret_sts:'||:l_ret_sts||':SECURITY');
    else
    v_text := 'begin ${L_PLSQL_PROG}(p_ret_type => 0, p_ret_sts => :1, p_ret_msg => :2);end;';
    execute immediate v_text using in out :l_ret_sts, in out :l_ret_msg;
    dbms_output.put_line('l_ret_sts:'||NVL(:l_ret_sts,0));
    dbms_output.put_line('l_ret_msg:'||:l_ret_msg);
    end if;
    end;
    exit
    ENDOFSQL
    Cheers
    Ian.

  • Multi row update not occuring

    I have created a tabular form using the wizard. This form will show three columns (and in addition a checkbox). I would like this form to be updateable in only certain instances. Because of that, I select the columns twice. I make one of them updateable, and the other read-only. Then I have a conditional display for the columns, so that the updateable columns are shown if a status variable in my page is 'EDIT' and the read-only columns are shown otherwise.
    The problem is that the multi row update does not occur. If I show one of the read-only columns when in the edit mode, the update is done. Also it is executed if I show one of the editable fields when the page is not in edit mode. But when I show only the editable fields in edit mode, and only the read-only fields when in read-only mode, the process is not run.
    What can I do about this? Why doesn't the multi row update occur?

    An alternative is to control the updates by controlling the buttons. Only show the submit/update button if the status on the page is "EDIT".

  • Multi-Row Update form with wrapped fields

    Hi,
    I have a multi-row update form with too many fields to fit on the screen without having to scroll. Is it possible to wrap the extra fields onto a 2nd line.
    So each DB record will actually span 2 srceen rows and fit nicely into my browser ??
    Thanks for any help,
    Brandon

    It is possible, but would require some serious work on the report template, to create a custom row template.
    I started to do this at http://htmldb.oracle.com/pls/otn/f?p=24317:191 but realized that it is hard work. Also, where would you show the headings for the second part of the row (split onto the next line)?
    Instead, I would use the Show/Hide columns technique (client-side scripting) to reduce the number of columns shown. Search for it on this forum. Carl and I have some good examples out there.

  • Multi Row Update Error

    Hello Everyone
    I get the following error when attempting to perform a multi row update. Is anyone able to advise what the issue is?
    Error in mru internal routine: ORA-20001: Error in MRU: row= 1, ORA-20001: ORA-20001: Current version of data in database has changed since user initiated update process. current checksum = "F71A42E70B86E7C8A14343633169264E", item checksum = "43A7146FE322237B683C4139D66E4DC5"., update "CSS_PRODUCTIVITY"."CENTREDATAASSOCIATIONS_TEST" set "MONTH" = :b1, "TM1_PREMISE_NAME" = :b2,

    hi oolite
    i can't help you with your problem
    but i have one suggestion
    i don't know whether you created your tabular form with the wizard or manually
    when you use the wizard
    i would suggest that you try to build a tabular form manully
    in fact it is a little bit more work but i think all what you have done by yourself
    is more transparent and errors should be found easier
    other suggestions take a look
    Error in mru internal routine: Error in MRU
    Error in mru internal routine
    or search for error on mru
    sorry that i can't tell you more

  • More than one multi row update region on one page - how ?

    Hi.
    I have a page on which i want to use two multi row update regions ( updateable report with three buttons like new/delete/save ).
    But i do not find a setting for the MRU-Process oder "Add-New-Line" Process that lets me reference this process to a specific region.
    The problemm is, that after adding the second region to the page, the "Add-New-Line" - process only adds the new line to the second region and not to the first region anymore.
    How can i make two processes where one adds a line to region1 and the second adds to region2. Same question is with updates too. How can i say that process on updates the changes in region1 and the other process updates the changes in region2 ?
    Thanks for help.
    greetings
    bernd

    Unfortunately, the builtin MRU process supports only 1 updatable region per page.

  • How to send message to a multi-consumer queue using pl/sql

    How to send message to a multi-consumer queue using pl/sql ? Thanks.
    I tried following, but got an message: no receipient specified.
    DBMS_AQ.ENQUEUE(
    queue_name => 'aqadm.multi_queue',
    enqueue_options => queue_options,
    message_properties => message_properties,
    payload => my_message,
    msgid => message_id);
    COMMIT;
    END;
    /

    Here's two way to enqueue/publish new message into multi-consumer queue.
    (1) Use explicitly declared recipient list
    - Specify "Recipients" by setting recipient_list to messge_properties, before ENQUEUE().
    DECLARE
    recipients DBMS_AQ.aq$_recipient_list_t;
    BEGIN
    recipients(1) := sys.aq$_agent('RECIPIENTNAME',NULL,NULL);
    message_properties.recipient_list := recipients ;
    (2)Or, declare subscriber list permanently. Then you need not to specify recipient list each time you call ENQUEUE().
    begin
    dbms_aqadm.add_subscriber(
    queue_name=>'YOURQUEUE',
    subscriber=> sys.aq$_agent('RECIPIENTNAME', null, null)
    end;
    You can add 1024 local subscriber include maximum 32 remote-queue-consumer to one queue.

Maybe you are looking for

  • Developer toolbar hiding icons previously accessible

    I used to have a number of icons at the bottom of my browser page such as Adobe Browser Lab, Downloadhelper. However the bar at the bottom of the page which is activated by clicking on Tools/Web Developer/Developer Toolbar has hidden them and even wh

  • Alsa suddenly not working

    Strange thing happening today : I have no sound anymore I made an update last night (last update was a long time ago). I tried to run alsaconf and I got this message : Configuring snd-*** Do you want to modify debug ? Configuring [lib/liblow.c(210)]:

  • SONY ERICSSON DOESNT SUPPORT MAC

    Its REALLY unbelievable. Since i was a child i used to buy all the time SE mobile phones. BUT now it is the last time! I recently bought an iMAC and i tried to tranfer a MOVIE from my MAC to the phone with Media Sync software. (It is the MEdia GO but

  • How to build timeout in BPEL flow?

    Can someone tell me what activities and service to use to build timeout? I could use 'Flow' and put one of the parallel activities as 'Wait'. But how to make the process continue when wait timeout?

  • Equal column heights ?? Help!

    I am trying to use example from projectseven: http://www.projectseven.com/tutorials/css/pvii_columns/col2fixed.htm. It looks ok in firefox, but does not in IE . The left sidebar does not equal maincontent div. Your help would be appreciated and if yo