How to refer to the primary key column of newly inserted rows of tabular form

Hello

I use APEX 4.2.0.00.27 with Oracle DB 11.2.0.3.0.

I work with a tabular presentation wizard-created for insert and update a table using the integrated SRM process (sequence 10).  I'm trying to use a process of anonymous block of PL/SQL (sequence 30) to make another manipulation of table after the records were inserted or updated.  The manual process is associated with my tabular form and I use the variables of name of column binding in my program block.

My (rsn_test) table has 3 columns: test_id (number), test_nbr (number), test_id2 (number).  Test_id column is identified as the primary key and the type of the source already exists a sequence rsn_test_seq.  Column test_id2 gets its default value 0 to a hidden page element.

I would use my manual process for updating the value of the test_id2 column.  If it's 0 then I want to put the value of the column test_id.  If it is any other value, then it must remain at this value.  My logic works very well for an existing line, but I'm running into a problem with the newly added lines.  The new lines get inserted, but the test_id2 column remains the default value 0.  I can tell the debugger that the SRM process is triggered first and inserts the line, then my manual dealing with fires.  The problem seems to be that the connection variable: TEST_ID for the primary key column remains NULL after insertion.  I don't know how to get the value of the column test_id of my newly created line to use in my PL/SQL block to my update.

Process of PL/SQL:

DECLARE
BEGIN
   :P7_SHOW := NULL;
   :P7_SHOW := NVL(:TEST_ID2,555) || ' and ' || NVL(:TEST_ID,787) || ' and ' || NVL(:TEST_NBR,9999);
   IF :TEST_ID2 = 0 AND :TEST_ID IS NOT NULL THEN
      UPDATE rsn_test
         SET test_id2 = :TEST_ID
       WHERE test_id = :TEST_ID;
   ELSE
      :TEST_ID2 := :TEST_ID2;
   END IF;
END;

Excerpt from the debugger:

0.01625 0.00010 Processes - point: ON_SUBMIT_BEFORE_COMPUTATION
0.01635 0.00008 Branch point: Before Computation
0.01643 0.00003 Process point: AFTER_SUBMIT
0.01646 0.00022 Tabs: Perform Branching for Tab Requests
0.01668 0.00008 Branch point: Before Validation
0.01676 0.00024 Validations:
0.01700 0.00135 Perform basic and predefined validations:
0.01835 0.00020 Perform custom validations:
0.01855 0.00049 ...Validation "TEST_NBR must be numeric" - Type: ITEM_IS_NUMERIC
0.01904 0.00007 ......Skip for row 1 because row hasn't changed
0.01911 0.00016 ......Skip for row 2 because row hasn't changed
0.01927 0.00012 ...Validation "TEST_ID2 must be numeric" - Type: ITEM_IS_NUMERIC
0.01939 0.00007 ......Skip for row 1 because row hasn't changed
0.01945 0.00018 ......Skip for row 2 because row hasn't changed
0.01964 0.00005 Branch point: Before Processing
0.01968 0.00004 Processes - point: AFTER_SUBMIT
0.01972 0.00588 ...Process "ApplyMRU" - Type: MULTI_ROW_UPDATE
0.02560 0.00154 ...Execute Statement: declare function x return varchar2 is begin begin for c1 in ( select "RSN_TEST_SEQ".nextval pk from sys.dual ) loop return c1.pk; end loop; end; return null; end; begin wwv_flow.g_value := x; end;
0.02714 0.00140 ......Row 3: insert into "APPPCSRSN"."RSN_TEST" ( "TEST_ID", "TEST_NBR", "TEST_ID2") values ( :b1, :b2, :b3)
0.02854 0.00011 ...Process "ApplyMRD" - Type: MULTI_ROW_DELETE
0.02865 0.00004 ......Skip because condition or authorization evaluates to FALSE
0.02869 0.00015 ...Process "Process Submit" - Type: PLSQL
0.02884 0.00007 ......Skip for row 1 because row hasn't changed
0.02891 0.00012 ......Skip for row 2 because row hasn't changed
0.02903 0.00012 ......Process row 3
0.02915 0.00429 ...Execute Statement: begin DECLARE BEGIN :P7_SHOW := NULL; :P7_SHOW := NVL(:TEST_ID2,555) || ' and ' || NVL(:TEST_ID,787) || ' and ' || NVL(:TEST_NBR,9999); IF :TEST_ID2 = 0 AND :TEST_ID IS NOT NULL THEN UPDATE rsn_test SET test_id2 = :TEST_NBR WHERE test_id = :TEST_ID; ELSE :TEST_ID2 := :TEST_ID2; END IF; END; end;
0.03344 0.00013 ...Session State: Saved Item "P7_SHOW" New Value="0 and 787 and 1300"
0.03356 0.00004 Branch point: After Processing
0.03360 0.00048 ...Evaluating Branch: "AFTER_PROCESSING" Type: REDIRECT_URL Button: (No Button Pressed) Condition: (Unconditional)
0.03407 0.00013 Redirecting to f?p=290:7:8717971109610:::::&success_msg=0%20row(s)%20updated%2C%201%20row(s)%20inserted.Success%2FEBD244168556408CBA714E3974918C09%2F
0.03420 0.00012 Stop APEX Engine detected
0.03432 0.00007 Stop APEX Engine detected
0.03439 - Final commit

Any suggestions?

I have run tests on

https://apex.Oracle.com/pls/apex/f?p=83488:1 demo/demo

to see your problem.

I have 2 solution for your problem.
I add trial NOT tabular just usual block of PL/SQL

BEGIN
I'm IN (SELECT TEST_ID FROM RSN_TEST WHERE TEST_ID2 = 0)
LOOP
      UPDATE RSN_TEST
         SET test_id2 = TEST_ID
       WHERE test_id = i.TEST_ID;
  END LOOP;
END;

and works very well, you can see in the sample.

The other solution is to show new generated TEST_ID

Adding a sequence as a default value for a column in a table field

And to execute your procedure.

I get how is with the good luck of time.

By

Tags: Database

Similar Questions

  • How can I update the primary key column

    Hello
    Can you suggest me best workaround/algorithm for task below:

    (Oracle 10g, Solaris OS.)
    Location:
    Table a primary key column P 'Code', tables children F1, F2,..., reference to F15 "Code_P' foreign key column"P.Code"column, and we do not know which of the child tables data available for a particular value"P.Code.
    Task:
    Change the value "P.Code" from 100 to 200. So that the result would be that record P [Code = 100] should be updated:
    update P set
    Code = 200
    where Code = 100;
    And child tables 'Code_P' column should be updated as:
    update F1, F2, .., F15 set
    P_code = 200
    where P_code = 100;
    The best solution would be that you can easily repeat this task.

    Edited by: CharlesRoos the 28.12.2010 12:10

    Will there be FK constraints in place?
    If so, you may need to modify them so that their application may be temporarily deferred.

    The gameplan would be something like this:

    -Making of CF can be deferred, immediate departure.
    -Alter FK set delay.
    -Update of Parent table.
    -Update of the children tables.
    -Immediate constraints set
    s ' engage;

  • How to find the primary key columns in the tables in MS Access using SQL queries

    How to find the primary key columns in the tables in MS Access using SQL queries

    Hello

    This is the forum for Windows Vista programs related issues.

    For better assistance, please try instead the Forums in SQL Server .

    Thank you! Vincenzo Di Russo - Microsoft MVP Windows Internet Explorer, Windows Desktop Experience & security - since 2003. ~ ~ ~ My MVP profile: https://mvp.support.microsoft.com/profile/Vincenzo

  • How to convert a single column in the primary key column

    Hi all

    I have a column that's unique cnstraint, this column contains the value as digital and also null.

    So how do you convert to primary key column

    Concerning
    Prashant

    Prashant wrote:
    Hi all

    I have a column that's unique cnstraint, this column contains the value as digital and also null.

    So how do you convert to primary key column

    Concerning
    Prashant

    Prashant,

    You must assign new values to null values. You can use a sequence to produce the figures in this column.

    Select max (your_unique_column) from your_table; -find the maximum value of this column, so you can start the sequence of this number.

    create sequence seq_for_your_table with XXXX - value max + 1 you have found

    Update your_table set your_unique_column = seq_for_your_table.nextval () where your_unique_column is null

    You can create a primary key on this column.

    Best regards

    Grosbois

    -------------------------------------------------------
    If you answer this question, please mark appropriate as correct/useful messages and the thread as closed. Thank you

  • Returns the primary key of the new line (generated by the trigger) to an insert procedure

    Hello
    I have a table with a primary key (number), which increases with the trigger
    I use a procedure to insert data into this table
    How can I find the primary key of the row inserted to this procedure?

    When you make use of the insert:

    INSERT .... RETURNING key_column INTO variable;
    

    (where key_column is your key on the table column and variable is a variable to store the value of the same data type)

    to get the value in a variable.

  • See the primary key

    I have a form on a report and the primary key is not visible. In its place in the column is the button change. How do we guarantee that the primary key is visible as well as change the button?

    jclarke,

    There are two ways to do it. If you hold the button change then the best thing to do is to remove the 'link' information associated with the primary key column (remember / note the details for the next step) so that it displays normally.

    Then go to the page report attributes and in the menu on the right tasks, select 'add column link '. Configure it as the column ID is.

    Kind regards
    Dan

    http://danielmcghan.us
    http://sourceforge.NET/projects/tapigen
    http://sourceforge.NET/projects/plrecur

    You can reward this answer by marking as being useful or correct ;-)

  • Automatically fill the primary key

    We have Oracle database 10g. I've added a primary key column to my deo_language_resources_t of table with the following logic:

    -- 1. create sequences
    create sequences eod_lr_seq
    Start increment by 10 by 5
    MinValue 10 nomaxvalue
    NoCache;

    -- 2. Create the primary key column
    ALTER table deo_language_resources_t
    ADD NUMBER RESOURCE_ID;

    -- 3. Fill the pk
    Update deo_language_resources_t
    Set id_ressource = eod_lr_seq.nextval
    where id_ressource is null;

    -- 3. Create the primary key constraint
    ALTER table deo_language_resources_t
    Add constraint resource_id_pk key (resource_id) primary;

    insert into deo_language_resources_t
    (first_name, last_name, id_ressource)
    values ('John', 'Doe', eod_lr_seq.nextval);

    The last INSERT statement successfully a line inserted into the table and populated by id_ressource with the next number in the sequence eod_lr_seq. Ok.

    Is it possible to set a constraint on deo_language_resource_t so that when I INSERT a line the id_ressource is automatically set to eod_lr_seq.nextval? It is possible to define a trigger and resembling the logic of the trigger? The insert statement would be like:

    INSERT INTO deo_language_resources_t (first_name, last_name) VALUES ('John', 'Doe');
    create trigger deo_language_resources_trigger
    before insert on deo_language_resources_t
    for each row
    begin
    select eod_lr_seq.nextval into :resource_id from dual;
    end;
    
  • How to fill out the table foreign key to the primary key form

    Hi all

    I'm stuck in this problem for 3 days, and I'm about to research and implement solutions on the internet.

    I have two tables

    create table prim (a number primary key, b varchar2 (100));

    create table CHILD (a number references (a) prim, varchar2 (100)) c;

    I created a page for PRIM table.

    = page name form on PRIM2

    I have manually two columns for the CHILD table to know

    P26_A_1 (for the primary key in the CHILD table)

    P26_C (for the column in the CHILD Table c)

    now when the user clicks on the button CREATE, a row must be inserted into the child table.

    I want to assign the P26_A to P26_A_1 during the validation process, so that a line must be inserted into the PRIM table as well as in the CHILD table.

    How to do this?

    I downloaded my application page in https://apex.oracle.com

    my workspace identifiers are inferior to

    name of the workspace = IMBERT

    username = demo

    password = demo

    kindly guide me.

    Thank you.

    Hello

    I created a new page (page 30) similar to your page and added the insertion of the child. It just check the page and code. It works now, when you insert the prim file is triggered a second trial which inserts the child record manually.

    On page 26 it was some sort of mistake, was easier to create a new as it was almost a standard form.

    Concerning

    Bottom

  • How to extract the values of the line full in the bean to support using the primary key

    Hello

    I have a table that has columns as plant_name, business planner email id and identification of email resident engineer. Here, Plant_name is the primary key.

    Now, I have this plant's name slipped and dropped like selectonechoice (drop) on page jsff. In this user can select any name of 1 plant drop down.

    Right now, I can go get plant in backing bean name, but I can't understand how business plan for extraction and identification of email of the engineer resident in this key primary-plant_name at the bean to support.

    Please let me know if anyone has an idea in this regard.

    JDeveloper version 11.1.1.6.0

    Thanks in advance.

    Sneha

    Sneha211 wrote:

    On the jsff page

    required = "#{bindings." Plant.hints.Mandatory}.

    shortDesc = "#{bindings." Plant.hints.ToolTip}.

    ID = "soc1" unselectedLabel = "- Select -"

    autoSubmit = 'true '.

    Binding = "#{backingBeanScope.backingbean.plantbean}" > "

    ID = "si1" / >

    In backing bean

    DCBindingContainer = lBindingContainer

    (DCBindingContainer) BindingContext.getCurrent () .getCurrentBindingsEntry ();

    DCIteratorBinding lBinding = lBindingContainer.findIteratorBinding("SupplierVO1Iterator");

    NewRow row = lBinding.getCurrentRow ();

    String aamplant1 = (String) newRow.getAttribute ("Plant");

    Hi Sneha, you've written code for it

    you have found the current line and the primary key then this line, then why you not not using this same rank to get the other attributes?

    NewRow row = lBinding.getCurrentRow ();

    String aamplant1 = (String) newRow.getAttribute ("Plant");

    String businessPalnner = (String) newRow.getAttribute ("business_planner"); Returns the value of the same line

    Engineer in String = (String) newRow.getAttribute ("engineer");


    OR if your condition is like that-

    you have a primary key field value, but you do not have the corresponding line, then you can get that line and it's attribute by using the primary key value

    See - http://adfgouravtkiet.blogspot.in/2012/10/filtering-of-data-from-vo.html

    Hope it helps

    -Ashish

  • How to use a Select list on a second primary key column in a tabular presentation?

    Hello

    I created a tabular presentation located on the details page of the user (form), that allows to manage roles for this user.

    The shape of table contains 3 elements:
    -> a checkbox
    -> user (PK) column is hidden, and its default value is generated by a function pl/sql (to submit the time), which refers to the element to username.
    -> the role of the column is displayed as a named select list LOV: add you a line, choose a role, submit, etc..

    But my ROLES table (not created by me...) contains 2 columns: USER and GRANTED_ROLE.
    The USER is the primary key, but a user can have multiple roles (= one line per role).
    GRANTED_ROLE is the second primary key, so that we can differentiate between one line of another.

    At the moment my tabular form has only one primary key (USER), so the GRANTED_ROLE can display as a list select.
    But, for this reason, in my opinion, remove the button do not work: all the lines of the user have the same key, so when I select a few lines to remove these, all lines in the form of tables are deleted.

    I don't know how my button Delete could recognize the subkey to remove only selected rows...
    Or maybe I should use a different type of region?

    Thanks for your help!
    Fanny

    In the process of ApplyMRD, try to specify the 'secondary key' column in the section "Source: Multi line Update and Delete"to the second column key in tabular form.»

    I have not tested this with your situation, but worth it.

  • How to get generated automatically the primary key to create procedure

    I have a service of physical data corresponding to a table named ACCOUNT. The primary key on the table is called ACCOUNT_ID. There's a trigger on the database which generates the primary key value and adds it during an insert. I would like to have this primary key value returned by the procedure of creation of physical data service. Any ideas on how this can be done? Thanks in advance.

    as the primary key automatically obtained by ODSI leave a sequence in the DB and used during a procedure for creating

    Go to the design for the physical data service view

    Click the column which is filled from the sequence.

    In the Properties tab (bottom window), under general, for automatic numbering, click the 'Value' column, select sequence. You get a noise on some things have changed, just click OK. With AutoNumber = sequence setting, this column appears as optional (question mark).

    Just below that, for purpose of sequence, type the name of the sequence (you can also specify MYSCHEMA. In case the sequence SEQUENCE_NAME is under another schema).

    When you create objects SDO - leave the update vacuum column.

    that is if he were CUSTOMER_ID, your client would look like this...


    John
    Smith

    and when you read it back to the database, it would be...


    38738
    John
    Smith

    Published by: mikereiche on April 28, 2009 11:40

  • APEX do not allow to change the lines of the columns that are the primary key?

    I have pictures:
    http://img508.imageshack.us/my.php?image=21269582oe8.jpg


    Book (id_book - 'Primary key', title, year); book_author (id_author id_book - 'Primary key', - 'Primary key'); author (id_author - "Primary key", name)



    I created a new page-> Form-> form of 'author' table because I want to add new authors, modification and deletion. During the creation of this page, I have chosen column 'id_author' as '1 primary key column' and everything is OK (I can't edit the 'id_author' column - this column is autoincrement and I can change the 'name' column).

    BUT I also created a new page-> Form-> table for table "book_author" because I like to write numbers like id_book and id_author, change and remove them (so add relations between tables: book, book_author and author). During the creation of this page, I have chosen column 'id_book' as '1 primary key column' and 'id_author' as 'column primary key 2'. And on the Web site, I can't edit these fields. And I can not add also new line because I see in each new line: (null).

    http://img444.imageshack.us/my.php?image=11324615yk9.jpg

    APEX do not allow to change the lines of the columns that are the primary key? It's stupid... What can I do?

    Edited by: user10731158 2008-12-20 11:40

    Column unique and not meaningful if you ever want to update. In the case of your example, you need to add an ID column in the intersection of book_author table. Honestly, I was so blown away (and pleasantly surprised) by the absence of rebuttal and the "thx" I advanced and set up an example of how I would define the book_author table:

    create table  book_author
       (id varchar2(32),
        book_id varchar2(32),
         author_id varchar2(32),
         modified_on     date,
         modified_by varchar2(255),
         constraint book_author_pk primary key (id),
         constraint book_auth_book_fk foreign key (book_id) references books(id),
         constraint book_auth_author_fk foreign key (author_id) references authors(id)
         )
    /
    
    create unique index book_author_uq on book_author (book_id,author_id)
    /
    
    create or replace trigger  biu_book_author before insert or update on book_author
    for each row
    begin
         if inserting then
              :new.id := sys_guid();
         end if;
         modified_on := sysdate;
         modified_by := nvl(v('APP_USER'),user);
    end;
    /
    

    Good luck
    Tyler

  • How to generate the primary key element and move to another page?

    How to make the primary key value to another page in a table?

    Form on T_ITEMS 2.png

    Hello

    I am a beginner in the apex,

    Please, now I want to add the primary key to page 1 for item id in page 2...

    Notice:

    Before, I created (process of pl/sql in the rendering of page @ after the header section) to get the id of secuance.

    BEGIN
    :P17_ID := seq_t_items_id.NEXTVAL;
    END;
    
    
    

    primary key is generated for the element ID of page 1... BUT When I update 'page 1' I see error and solved when shut down my browser and open it again...

    Please help me to...

    1. Generate a primary key (article id @ page 1)... without refresh error. ?
    2. Pass him (item_id) on page 2

    Thank you all for...

    Sorry I'm beginner in apex,

    I don't know how Pass value of the item_id TO page 1 page 2 "in the form ID", turn to the first PHOTO... .
    Help me..

    Thank you

  • Diagram of all the tables list of primary key column names

    Hi people,

    I have a Scott user for example, I want to retrieve all tables primary key column names in the user Scott.

    can someone help me please.

    Thanks in advance,
    karmaya

    You can log in to SCOTT and try this

    select c.constraint_name
         , cc.table_name
         , cc.column_name
      from user_constraints c
      join user_cons_columns cc
        on c.constraint_name = cc.constraint_name
     where c.constraint_type = 'P';
    
  • Hi cannot see the column in the primary key as a master detail

    I have a form master detail. In the first form master, I am unable to see the primary key
    Now, the form is based was completely and I'd also like to see the visible primary key column in the main report


    If I put the primary key as rowid then I should have seen the primary key.
    Now I can see the pencil icon (the icon of pencil to the rank nedopil) instead of the actual primary key column. who's a number of data...
    I'd like to be too visible. Can we guide what should I do for this...
    Thank you

    Are not only in the hidden items? Change the settings for them to be unhidden.

Maybe you are looking for

  • GET A WIDGETWINERROR. HTML

    After you have uninstalled chrome whenever I run firefox I get this message chrome://allottabgen/content/allottb-widgetwinerror.htmlI tried to reinstall, tried resetting the default home page, deleted same error in cache even now this is happening at

  • Why all my favorites not copied to Favorites when I downloaded Firefox?

    All my favorites were not copied on bookmarks. Only Favorites A - H appear in my favorites, the rest of them aren't there. Why didn't he not copied all my favorites?

  • How to import bookmarks in V11?

    I found several articles on how to import bookmarks, but they refer to "Manage bookmarks" in the bookmarks menu and the option does not appear in version 11. I prefer not to re-create all my favorites, and they appear not in a friendly way when I pul

  • Portege 4000 - I would like to upgrade memory: 256 MB to 512 MB

    Hello I have a Portege 4000 and want to upgrade the memory: 256 MB to 512 MB.It has 98SE and the user always wants to keep this system. Does anyone know if there is a known issue with the upgrade to 512 MB I saw a thread in 2005, by someone who had a

  • Photo ring

    Hi all I would like to know if there are other ways outside the use of ring of photo for the photos I want to display on my control panel. Because I do not know how to control my photo ring to let appear depending on the outcome, based on some button