Automated Row Fetch for complex primary keys

I would like to post a workaround for using automated row fetch on tables with a complex primary key (more than 2 components).
APEX has the restriction of just beeing able to handle <= 2 PK components, which is not acceptable to me in quite a lot of scenarios.
Imagine a situation where you want to manage recipes for dishes. Each recipe has several versions and each version has several recipe-positions. The PK consists of recipe_id, recipe_version and recipe_position.
You hava a report displaying the positions of a specific recipe version and this report contains an edit link that jumps to a form, where the attributes of a recipe position can be edited.
Creating the edit position form, you can only specify a primary and a secondary key item/column. Given that, if you want to use the edit form by clicking the edit link, you will receive the error "ORA-01422: exact fetch returns more than requested number of rows", because the third PK compound is not used as a restriction.
The workaround is to present the ROWID pseudo-column to the form as the primary key.
Create a (hidden) Item to store the ROWID-Value of the current row and simply change the properties of the ARF-Process to accept ROWID as the PK column and specify the corresponding item.
If automated processing of recipe_position is desired, you can specify it as the secondary key column.
I don't know if this woraround/solution is very ugly, but it works ...
Ingo

Hello Ingo,
I tend to avoid ROWID. In the Interactive Report it's used too.
The ROWID can change, where a Primary Key normally doesn't change, that's the biggest thing I worry about. How does Oracle know not somebody else already updated the row?
I always wonder what happens when you're in a cluster/RAC and use ROWID. Isn't it possible that you get two rows for the same rowid?
Just my thoughts.
Regards,
Dimitri
-- http://dgielis.blogspot.com/
-- http://apex-evangelists.com/
-- http://apexblogs.info/

Similar Messages

  • Automated Row Fetch

    I am struggling to get two forms on the same page work as they are suppose to. One of the problems is with Automated Row Fetch. To condense the problem I tried the following (on a test page):
    Created a form/table on table A with primary key PK_A
    Among other things this creates the automated row fetch for this form and a field P1_PK_A. containing the PK.
    Created another form/table on table B with primary key PK_B which creates automated row fetch for B and P1_PK_B
    Since I am concentrating on fetch process deleted all buttons and processes except FETCH row for both forms.
    Now:
    When I pass a value to P1_PK_A in the URL and no value for P1_PK_B it fetches the row in form A fine, same is true the other way around. However if I pass valid keys for both forms in the URL it fails to fetch row for the second form.
    Am I missing something or if not how am I to have two forms on a page?

    Thanks for the quick response Joe,
    I deleted the process created by the wizard and created another data manipulation process with the wizard - which created another autmated row fetch and makes no difference. By creating the fetch and DML manually do you mean that I have to create PL/SQL process to fetch the values for the second form?
    Btw how in the world I missed the part that you can't have two automated DML processes on a page I don't know.

  • Two 'Automated Row Fetch'-processes at one page

    All,
    I have a page with several fields (P24_xxx_Reg1 & P24_xxx_Reg2) in two regions.
    For every region I have an ‘Automated Row Fetch’-process, because they base on different tables.
    The second process sets the field values of region 1 to null,
    even all is different: fieldnames, sources, regions, processes, etc.
    Any help appreciated,
    thanks in advance
    lucio

    Create a view on a table you want to update if you have more than two key values.
    However, the automated row fetch does support two key values.
    Denes Kubicek
    http://deneskubicek.blogspot.com/
    http://www.opal-consulting.de/training
    http://htmldb.oracle.com/pls/otn/f?p=31517:1
    -------------------------------------------------------------------

  • Automated row fetch returns more than one row

    Greetings All,
    Does anyone know of a way to call a page if the automated row fetch returns more than one row. I have a form with a primary and secondary key. If I search only on the primary key and there is more than one row I would like to call a popup with the multiple list, is this possible?
    Regards
    Mark

    Create a view on a table you want to update if you have more than two key values.
    However, the automated row fetch does support two key values.
    Denes Kubicek
    http://deneskubicek.blogspot.com/
    http://www.opal-consulting.de/training
    http://htmldb.oracle.com/pls/otn/f?p=31517:1
    -------------------------------------------------------------------

  • Automated row fetch / Complex primary key

    I have a complex primary key made up of ticket_num, ticket_seq because there may be between 1-3 rows associated with one ticket_num.
    The problem I am having is the automated row fetch errors out when trying to update a ticket with the following error even though the combination of ticket_num, and ticket_seq are unique, and ticket_num, ticket_seq are entered in the automated row fetch as primary key column, and secondary key column.
    ORA-01422: exact fetch returns more than requested number of rows
    Is there a way to put both columns as the primary key?

    Thanks, Scott. I had the exact same problem, and your suggestion fixed it.
    May I suggest that this is a bug in Apex? In the create application wizard, select "Add Page" -> "Report and Form", and select a table with a compound primary key consisting of two columns. Apex will create the report and the form, and will configure the ARF correctly in the form, but it does not specify a value for the second key in the Link Column section of the report attributes.
    Thanks,
    Mike

  • Table and Primary Key Case Sensitive in Automated Row Fetch

    Why are the table and primary key fields case sensitive in the Automated Row Fetch process? I'm debugging an error in this process and I'm not sure what the case should be.

    Russ - It's a defect of sorts. Use upper case in the process definition. I don't think these processes will work with tables or columns whose names are not known to the database as upper-case values, i.e., defined using double-quoted non-upper case.
    Scott

  • Checking for duplicate primary keys on row inserts

    Checking for duplicate primary keys on row inserts
    I have a situation where I will be making bulk table inserts knowing that the primary key value will in some cases already exist. In this is the case I simply want to ignore the duplicate inserts.
    Should I be performing a sub-query on the table and using a statement like:
    where not exist in
    Or is there a cleaner way of discarding or checking for duplicates on insert.
    My concerns were mainly one of performance, as my routine will be inserting a few thousand rows in its operation.

    The MERGE commnad is a good option when a large percentage of the data will exist in the target because it is much more efficient to attempt to update then insert when the update affects zero rows than capture an error and convert it to an update.
    However, since in this case it would appear that only a few rows will alreadys exist and we want to ignore the duplicates when they exist then
    begin
    insert
    exception
    when dup_value_in_index then null;
    end
    would be the way to code this one. The bulk insert version has in 9.2 the ability to store the errors so that they can all be handled at once which means the rest of the array insert can work.
    HTH -- Mark D Powell --

  • How to trigger the automated row fetch process and open modal window by javascript api?

    Hi,
    I would like to click the one row of column of IR report, to open the modal window of current page.  <----------------it is ok. I can use "javascript:openModal('windowID')"  to do it.
    There is one form in this modal window, Meanwhile, I would like to pass column data to this form.    <--------------------- it is ok also. I can use " $s('P7_ID','column_value');" to do it.
    But I don't know how to trigger the "automated row fetch" process of this form to retrieve other field's value in this form.   
    I tried to use following 2 ways. But failed.
    First method:
    add one ajax process of "automated row fetch" in "page processing" block, named "get_fetch_data"
    when click IR column , call "openModal", and call  "apex.server.process ( "get_fetch_data", {}, { success: function( pData ) { }  } );"  , I tried to call above ajax process to refresh form. It is failed.
    Second method:
    add one process of  "automated row fetch" in "page rendering" block, named "get_fetch_data"
    when click IR column, call javascript api "apex.submit" to submit current page , then call "openModal".
    such as :  javascript:apex.submit({request:'MODIFY',set:{'P7_ID': #ID#}}); openModal('trade');
    But it is failed also. the modal page is showed firstly. then page refresh. but modal window will not open again.
    I am not sure if my thinking is right. Could you please provide any suggestion?
    Thanks in advance,
    Ping

    Hi Ping,
    You can try to set the session state of your modal page's primary key before opening the modal page. Use one dynamic action (on click of IR row) with two true actions. First one to set session state of modal page pk, second on to open modal page.
    Or you can add the modal page url as link in your report by extending your query:
    select ...
    ,         apex_util.prepare_url( 'f?p='||:APP_ID||':7:'||:APP_SESSION||'::'||:DEBUG||':7:P7_ID'||COLUMN_VALUE ) as link
    from ...
    This will give you the url of the modal page, with set primary key.
    Regards,
    Vincent Deelen
    http://vincentdeelen.blogspot.com

  • How do I obtain the next number for a Primary Key using an ADF View Object?

    I have two separate View Objects (A & B) for the same Entity Object. View Object A does a SELECT on all of the fields in the table. This View Object is where I execute my adds and updates. View Object B is only used to retrieve the next number for the primary key. This is done so that when I add a row to the database, I always get the max number of the primary key and add one to it. I accomplished this by setting the SQL mode to Expert and using the SQL: "SELECT MAX(NBR) AS MAX_NUMBER FROM TABLE_1". This may be overkill having a seperate View Object for this, but so far this is the only way I have found to obtain the next number. However, I have discovered that this way does not always work.
    The problem I'm running into is when I try to add multiple records to View Object A without committing the transaction between each add. Because View Object B is disconnected from View Object A, the MAX_NUMBER of View Object B comes back with the same number for each add I do on View Object A. So I know I must retrieve the MAX_NUMBER from View Object A.
    I've tried using the following code in my Table1ViewImpl class:
    this.setQuery("SELECT MAX(Table1.NBR) AS MAX_NUMBER FROM TABLE_1 Table1");
    this.executeQuery();
    The view object now has what I want, but I have yet to figure a way to extract the MAX_NUMBER out of the View Object. I've also looked into using the method addDynamicAttribute() but I can't figure out any way to set the attribute with the MAX_NUMBER.
    I can't be the only one trying to retrieve the next number from a database table using ADF. Can anyone help me with this? FYI - I'm using JDev 10.1.3 EA.

    You missing the point.
    On a multi-user db knowing the next highest number doesn't guarantee the number will be available when it comes time to commit the record. You can prove this to yourself by opening two instances of your app and do whatever you do to add a new record to your VO. Both will assume the same number, and when you commit an error will be generated
    You must use sequences to avoid the possibility of duplicate keys. If you are trying to avoid gaps in your numbering then you need to convince yourself why this is necessary.

  • Set memory cache - automated row fetch

    I would like to know more about the difference between
    Set Memory Cache On Display and
    Set Memory Cache On Fetch
    option, given in the Automated Row Fetch process.
    I noticed that it makes a difference in some cases - especially where I have a master-detail relation and need to perform multiple drill down:
    e.g. the report shows what was expected but export to .csv returns no rows. After switching from the default 'Set Memory Cache On Fetch' to 'Set Memory Cache On Display' everything works fine.
    Where could I find something about this option?
    Denes Kubicek

    Denes - I'd need to see an example to explain it. It is not the behavior I would expect. Can you create a simple test case on htmldb.oracle.com? Please post the workspace name and app/page ID when you have it.
    A bit more info: when the DML Fetch Mode is set to 'Set Memory Cache On Display', references to items sourced by the fetch, say &P1_ENAME., will not return the value that would be displayed in the form item P1_ENAME until after the code that emits P1_ENAME executes. So if your page had a before-header DML Fetch process that fetched a value for P1_ENAME (from EMP) and region A that displayed conditionally based on P1_ENAME = 'SMITH' and then region B containing the form item P1_ENAME and then region C that displayed conditionally based on P1_ENAME = 'JONES', the condition on region A would not see the fetched value of P1_ENAME but the condition on region C would see the value. However, if you set 'DML Fetch Mode to 'Set Memory Cache On Fetch', the condition in region A would see the fetched value.
    When you have a csv link or chart region that references a value from session state, that value must have been committed to session state (which happens when you run a computation, do an explicit assignment or "select into" a bind variable associated with a page or application item, or when you submit a form) in order for the csv or chart page to access the current value.
    Scott

  • Automated Row Fetch binding

    Hi Experts,
    Apex 4.1
    This is what i'm trying to do.
    I have number of fields in a form.
    Value for the Fields are fetched from two different tables using Automated Row Fetch.
    When the page loads only one ARF process would run based on a flag value in the application item and only those fields specific to that ARF should be populated.
    what i have noticed is when one ARF executed apex tries to bind all the fields on the form which have source type as Db column.
    in my case when it tries to bind a field which is basically populated by second ARF. it throws error message.
    What i what t know is,
    When we have multiple ARF on a page, is there any way to specifiy.. these fields are only populated by this ARF ?
    Really appreciate if someone can assisit me on this.
    Thanks
    T.kurubaran
    Edited by: Apex-Ape on Mar 29, 2012 1:12 AM
    Edited by: Apex-Ape on Mar 29, 2012 1:13 AM

    Apex-Ape wrote:
    what i have noticed is when one ARF executed apex tries to bind all the fields on the form which have source type as Db column. This is the expected behaviour of ARF processes.
    When we have multiple ARF on a page, is there any way to specifiy.. these fields are only populated by this ARF ?No.
    You should create custom row-fetch process to achieve this.

  • How to specify  tablespace for a primary key inde in create table statement

    How to specify the tablespace for a primary key index in a create table statement?
    Does the following statement is right?
    CREATE TABLE 'GPS'||TO_CHAR(SYSDATE+1,'YYYYMMDD')
                ("ID" NUMBER(10,0) NOT NULL ENABLE,
                "IP_ADDRESS" VARCHAR2(32 BYTE),
                "EQUIPMENT_ID" VARCHAR2(32 BYTE),
                "PACKET_DT" DATE,
                "PACKET" VARCHAR2(255 BYTE),
                "PACKET_FORMAT" VARCHAR2(32 BYTE),
                "SAVED_TIME" DATE DEFAULT CURRENT_TIMESTAMP,
                 CONSTRAINT "UDP_LOG_PK" PRIMARY KEY ("ID") TABLESPACE "INDEX_DATA"
                 TABLESPACE "SBM_DATA";   Thank you
    Edited by: qkc on 09-Nov-2009 13:42

    As orafad indicated, you'll have to use the USING INDEX clause from the documentation, i.e.
    SQL> ed
    Wrote file afiedt.buf
      1  CREATE TABLE GPS
      2              ("ID" NUMBER(10,0) NOT NULL ENABLE,
      3              "IP_ADDRESS" VARCHAR2(32 BYTE),
      4              "EQUIPMENT_ID" VARCHAR2(32 BYTE),
      5              "PACKET_DT" DATE,
      6              "PACKET" VARCHAR2(255 BYTE),
      7              "PACKET_FORMAT" VARCHAR2(32 BYTE),
      8              "SAVED_TIME" DATE DEFAULT CURRENT_TIMESTAMP,
      9               CONSTRAINT "UDP_LOG_PK" PRIMARY KEY ("ID") USING INDEX TABLESP
    ACE "USERS"
    10               )
    11*              TABLESPACE "USERS"
    SQL> /
    Table created.Justin

  • How to change the source type for a primary key on a form?

    Hi,
    At the time of creating a form, I had set the source type for the primary key to an existing sequence.
    Now I want to change the source to a trigger.
    Can anyone suggest how to do it?
    Thanks in advance,
    Annie

    Annie:
    Define the trigger and then delete the page process named 'Get PK'
    Varad

  • Creating a script for a PRIMARY KEY USING INDEX SORT doesn't work

    Probably a bug.
    h1. Environment
    Application: Oracle SQL Developer Data Modeler
    Version: 3.0.0.655
    h1. Test Case:
    1. Create a new table TRANSACTIONS with some columns.
    2. Mark one of numeric columns as the primary key - PK_TRANSACTIONS.
    3. Go to Physical Models and create new Oracle Database 11g.
    4. Go to Physical Models -> Oracle Database 11g -> Tables -> TRANSACTIONS -> Primary Keys -> PK_TRANSACTIONS -> Properties:
    a) on General tab set Using Index to BY INDEX NAME
    b) on Using Index tab choose a tablespace
    c) on Using Index tab set Index Sort to SORTED.
    5. Export the schema to DDL script. For the primary key you will get something like this:
    ALTER TABLE TRANSACTION
    ADD CONSTRAINT PK_TRANSACTION PRIMARY KEY ( TRAN_ID ) DEFERRABLE
    USING INDEX
    PCTFREE 10
    MAXTRANS 255
    TABLESPACE TBSPC_INDX
    LOGGING
    STORAGE (
    INITIAL 65536
    NEXT 1048576
    PCTINCREASE 0
    MINEXTENTS 1
    MAXEXTENTS 2147483645
    FREELISTS 1
    FREELIST GROUPS 1
    BUFFER_POOL DEFAULT
    ) SORTED
    h1. Reason of failure
    The script will fail because SORTED is not allowed here. It should be SORT.
    Additionally, the default behaviour for Data Modeler is to set Index Sort to NO but default setting for Oracle database 11g is SORT. Shouldn't Data Modeler use SORT as the default value?
    Edited by: user7420841 on 2011-05-07 03:15

    Hi,
    Thanks for reporting this problem. As you say, it should be SORT rather than SORTED. I have logged a bug on this.
    I also agree that, for consistency with the database default, it would be better to have SORT as the default in Data Modeler.
    David

  • [Incoming Payments for WTax] Primary Key not exist in DB

    While performing the TDS upgrade, I am getting an error message as "[Incoming Payments for WTax] Primary Key not exist in DB".
    I have checked that the sheet conforms to the instructions provided in the Upgrade guide but am not able to resolve this.
    Any ideas?
    Regards,
    Gyanesh

    Hi,
    It seems to be some field in the TDS upload Excel sheet which has primary key field not having the correct value.
    Double check the same where Primary Key if linked with some value in other sheet, enter the same.
    Kind Regards,
    Jitin
    SAP Business One Forum Team

Maybe you are looking for

  • ICloud eMail Address Deletion

    I have 2 iCloud email addresses under my Apple ID, one of which is an @me.com and one @icloud.com. When setting up iCloud on my IOS devices, it is easy to select which email address I would like to use, however when creating the iCloud account in the

  • IMac 24" Core 2 Duo 2.16GHz Memory issue

    I just received a refurb iMac 24" Core 2 Duo 2.16GHz that came with a single 1GB memory module. I bought a 1GB module from Crucial. When both modules are installed, the computer doesn't chime and doesn't have any screen image nor does it boot. After

  • BorderManager Cluster problems

    I have set up a 2 node NW 6.5 SP8 cluster to run BorderManager 3.9 SP2. I don't have a 'Split Brain Detector' (SBD) partition; the servers only monitor each other through the LAN heartbeat signal that is being sent by the master and replies by the sl

  • IPad 2 - Upgrading to iOS 6

    If I upgrade my iPad 2 to iOS 6 in Settings > General > Software update, will my apps, music and photos lost?

  • Where is Ink/Inkwell in Leopard?

    I have a Genius G-Pen 450 attached to my iMac running 10.5.1. The driver is recognized and the pen functions in applications such as Pixelmator, However Inkwell doesn't appear in Systems Preferences, and I am unable to find any reference to it anywhe