Updatable report without technical primary key

Hi,
I have a number of tables which need a standard updatable query report (MRU/MRD/MRI). However, these tables do not have a generated primary key, but the primary key is edited by the user.
I've tried generating a standard updatable report for this, however, this doesn't seem to work because it needs a generated primary key.
So I've tried to write the MRU process myself, which could work. However, how would I add a new row, because this isn't possible unless you use the standard updatable report!!... :S I can't help but think this must be me overlooking something. I can't imagine APEX cannot use standard updatable reports without a generated primary key!
Who can help?

The solution you're suggesting is the best in my oppinion as well, however, I would like to know if it's possible to resolve this issue in another way. Using technical key's is best practice, but it's not wrong if you don't... so why isn't there a way in APEX to handle this?
Maybe using the "Primary Key Source Type" as "Custom PL/SQL Function" in the "Tabular Form Element" is a possibility?
I will try to convince the customer (other IT department) to use a technical primary key and replace the user generated key by a unique constraint, but ... I just want to know :)
Edited by: Voxie2 on Jan 7, 2010 2:30 PM

Similar Messages

  • Dbtable without a primary key

    hi!
    is it possible to create a db-table without a primary key? if there is a possbility, how can i do this?
    greetings
    stefan

    Hello,
    The link i provided contains all your answers. Its oracle 8i documentation release. It contains everything that you want to know about oracle 8i release.
    What Are Index-Organized Tables?
    Index-organized tables are tables with data rows grouped according to the primary key. This clustering is achieved using a B-tree index. B-tree indexes are special types of index trees that differ from regular table B-tree indexes in that they store both the primary key and non-key columns. The attributes of index-organized tables are stored entirely within the physical data structures for the index.
    Why Use Index-Organized Tables?
    Index-organized tables provide fast key-based access to table data for queries involving exact match and range searches. Changes to the table data (such as adding new rows, updating rows, or deleting rows) result only in updating the index structure (because there is no separate table storage area).
    Also, storage requirements are reduced because key columns are not duplicated in the table and index. The remaining non-key columns are stored in the index structure.
    Index-organized tables are particularly useful when you are using applications that must retrieve data based on a primary key. Also, index-organized tables are suitable for modeling application-specific index structures. For example, content-based information retrieval applications containing text, image and audio data require inverted indexes that can be effectively modeled using index-organized tables.
    See Also: For more details about index-organized tables, see Oracle8i Concepts.
    Differences Between Index-Organized and Regular Tables
    Index-organized tables are like regular tables with a primary key index on one or more of its columns. However, instead of maintaining two separate storage spaces for the table and Btree index, an index-organized table only maintains a single Btree index containing the primary key of the table and other column values.
    Index-organized tables are suitable for accessing data by way of primary key or any key that is a valid prefix of the primary key. Also, there is no duplication of key values because a separate index structure containing the key values and ROWID is not created. Table 14-1 summarizes the difference between an index-organized table and a regular table.
    Table 14-1 Comparison of Index-Organized Table with a Regular Table
    Regular Table  Index-Organized Table 
    ROWID uniquely identifies a row; primary key can be optionally specified 
    Primary key uniquely identifies a row; primary key must be specified 
    ROWID pseudo-column refers to physical block address 
    ROWID pseudocolumn refers to primary key-based logical ROWID 
    Secondary indexes store physical data 
    Secondary indexes store primary key-based logical ROWID 
    Can be stored in a hash or index cluster 
    Cannot be stored in a hash or index cluster 
    Regards,
    Shekhar Kulkarni

  • How to do hibernate mapping for table or view without a primary key

    Hi,
    Anyone knows how to do hibernate mapping for table or view without a primary key?
    thanks.
    cc

    or you can make all column primary key .Anybody seriously considering that as a good idea should understand the implications:
    1. this requires that each row be unique - that's a minor issue normally, but can be a significant problem in some cases
    2. in practically all databases, a primary key constraint creates a unique index - this has many implications:
    a) in most databases, the index stores a copy of the column data that is indexed - this suggestion therefore more than doubles the data storage required for the data
    b) whenever an indexed column is changed, the index has to be maintained - this suggestion then more than doubles the work that each UPDATE statement has to do, since both the table and the index have to be maintained for any UPDATE at all
    This might work OK for toy projects, but it doesn't scale well at all...

  • Updating a transparent table primary key

    Hi Guys,
                  I am fixing a system copy error, for that plan to update the table through a program.
    The field I am going to update one of the primary key field.
    Is that possible to do it.
    Thanks

    Hi,
      if you are going to insert a record it is possible.
    if you are going to modify the existing record it is not possible to update the primary key you can only change the fields which are not primary key.

  • Implement Oracle Streams without having Primary Keys

    In our environment, we can't create primary keys so anyone know how to implement oracle streams without having primary keys on the tables.
    Thanks,

    You can JOIN tables on any compatible columns or functions (like LEFT (PONumber,10) ):
    http://technet.microsoft.com/en-us/library/ms191517(v=sql.105).aspx
    BOL: "When the (ON) condition specifies columns, the columns do not have to have the same name or same data type; however, if the data types are not the same, they must be either compatible or types that SQL Server can implicitly convert. If the data types
    cannot be implicitly converted, the condition must explicitly convert the data type by using the CONVERT function. "
    LINK:
    http://technet.microsoft.com/en-us/library/ms177634(v=sql.105).aspx
    Typically tables are JOIN-ed on FK-s and PK-s.
    Kalman Toth Database & OLAP Architect
    SELECT Video Tutorials 4 Hours
    New Book / Kindle: Exam 70-461 Bootcamp: Querying Microsoft SQL Server 2012

  • Getting the UPDATEd value and its primary key

    I have two procedures, proc1 and proc2.
    In proc1 there is an update happening like
    CREATE OR REPLACE procedure proc1
    as
    TYPE NumList IS TABLE OF employees.employee_id%TYPE;
    enums NumList;
    TYPE NameList IS TABLE OF employees.last_name%TYPE;
    names NameList;
    BEGIN
    UPDATE emp set sal=900 WHERE department_id = 30
    RETURNING employee_id, last_name BULK COLLECT INTO enums, names;
    DBMS_OUTPUT.PUT_LINE('Updated ' || SQL%ROWCOUNT || ' rows:');
    FOR i IN enums.FIRST .. enums.LAST
    LOOP
    DBMS_OUTPUT.PUT_LINE('Employee #' || enums(i) || ': ' || names(i));
    END LOOP;
    END;
    /In proc2 which is getting executed just after proc2 i want to SELECT the sal column values and its primary keys(employee_id) which got updated in proc 1.
    How can i achieve this?

    add two out parameters from proc1 so that you can pass them into proc2 (obv. you'd need to add two in parameters to proc2 if they aren't there already)

  • ON UPDATE CASCADE and Autoincrement primary key with Oracle SQL Developer

    hello everybody,
    I want to know if Oracle SQL Developer manage autoincrement on primary key and "ON UPDATE CASCADE" when i migrate (with data) SQL Server database in Oracle database.
    Can you help me ?
    Thanks for your suggestions.

    Obtain the value of the auto increment key with the getGeneratedKeys() method.
    Statement stmt = null;
    ResultSet rs = null;
    stmt = conn.createStatement(java.sql.ResultSet.TYPE_FORWARD_ONLY,
                                    java.sql.ResultSet.CONCUR_UPDATABLE);
    stmt.executeUpdate("DROP TABLE IF EXISTS autoIncTable");
        stmt.executeUpdate(
                "CREATE TABLE autoIncTable ("
                + "priKey INT NOT NULL AUTO_INCREMENT, "
                + "dataField VARCHAR(64), PRIMARY KEY (priKey))");
    stmt.executeUpdate(
                "INSERT INTO autoIncTable  (dataField) "
                + "values ('data field value')",
                Statement.RETURN_GENERATED_KEYS);
    int autoIncKeyFromApi = -1;
        rs = stmt.getGeneratedKeys();
        if (rs.next()) {
            autoIncKeyFromApi = rs.getInt(1);
        } else {
        rs.close();

  • How to code the ejbCreate() method without initailizing primary key?

    Hi all,
    I've just started learning about EJBs, and now am at the stage of learning how to create, deploy and test a CMP Entity Bean.
    Ran into a problem which I'm hoping someone can help out with.
    I'm using SQL Server 2000 as my backend database, and have created a simple table called TEST with 2 fields, id and name. id is set as the primary key, and as an identity conlumn. What this means is that when we do inserts, we don't need to specify a value for the id column. SQL Servers automatically generates that value.
    Here's my ejbCreate method in my bean class:
    public Integer ejbCreate(String name) throws CreateException {
        this.setName(name);
    }When I tried to run the create method from a web client, I got this error:
    javax.ejb.CreateException: [EJB:010148]In EJB 'SampleEJB', the primary key field 'id' was not set during ejbCreate. All primary key fields must be initialized during ejbCreate. at weblogic.rmi.internal.ServerRequest.sendReceive(ServerRequest.java:186) at weblogic.rmi.cluster.ReplicaAwareRemoteRef.invoke(ReplicaAwareRemoteRef.java:284) at weblogic.rmi.cluster.ReplicaAwareRemoteRef.invoke(ReplicaAwareRemoteRef.java:244) at everbright.ejb.SampleEJB_uzc4wg_HomeImpl_813_WLStub.create(Unknown Source) at jsp_servlet.__index._jspService(__index.java:152) at weblogic.servlet.jsp.JspBase.service(JspBase.java:33) at weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run(ServletStubImpl.java:996) at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:419) at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:315) at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:6452) at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321) at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:118) at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:3661) at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:2630) at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:219) at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:178)
    So it seems like I can't leave the id field uninitialized in the ejbCreate method. However I don't know what to initialize it with either, because in order to know what value I need to initialize it to, I'll need to run a db query to retrieve the next primary key value for the id field. This doesn't sound very efficient to me.
    I tried to initailize it to null, but that gave me a NullPointerException.
    Why do we need to initialize the primary key field in ejbCreate? Should the container do the insert and then get it from the table accordingly?
    Is there any other way I can get this set-up working?
    Thanks!

    Hi Fusion777,
    Ya, I've been searching around forums for an answer also. Apparently this is indeed a problem that has no general solution. It depends on 2 factors:
    1) Whether or not the database supports autogenerate key (which most does) and how (Oracle does it by sequences while SQL Server by identities)
    2) Whether or not the application server supports 1).
    In my case, I'm using SQL Server and Weblogic Server 8.1 and most fortunately, Weblogic does support identities and sequences. Just define the <auto-key-generation> stanza in your weblogic-cmp-rdbms-jar.xml deployment descriptor, as follows:
    <automatic-key-generation>
         <generator-type>ORACLE</generator-type>
         <generator-name>test_sequence</generator-name>
         <key-cache-size>10</key-cache-size>
    </automatic-key-generation>
    <automatic-key-generation>
         <generator-type>SQL-SERVER</generator-type>
    </automatic-key-generation>
    <automatic-key-generation>
         <generator-type>NAMED_SEQUENCE_TABLE</generator-type>
         <generator-name>MY_SEQUENCE_TABLE_NAME</generator-name>
         <key-cache-size>100</key-cache-size>
    </automatic-key-generation>I've tried that and it works :-)
    I gather from your reply that those who are using JBoss are equally fortunate :-)
    So I thought I'll share this in case some other poor fellow is facing the same problem as we are. At least worse come to worse, he'll have the option of switching to either JBoss or Weblogic and know that it works in both :-)
    Some other users seem to be against the idea of using auto-generated keys for precisely the reason that it is not a standard across database and application servers. See this thread:
    http://forum.java.sun.com/thread.jspa?forumID=13&threadID=329896
    I've in fact stopped working on EJB 2.0 and am exploring something called Hibernate, which seems to have a more generic way of dealing with the auto-generated key issue. In fact, I've heard news that EJB 3.0, which is the upcoming standard for EJB, will be heavily inspired by Hibernate as far as CMP Entity Beans are concerned.
    You can check out Hibernate at http://www.hibernate.org.

  • JPQL HOWTO:  "join" entities without foreign/primary keys?

    I have entities Person and Representative.
    Entity Person has fields lastName, firstName and patronymic.
    Entity Representative has field named title.
    The task is:
    Select all Persons and Representatives where representative.title contains Person.firstName, Person.lastName and person.patronymic.
    Person can have several representatives.
    Person and Representative don't have any keys. Is it possible to do it using JPQL or it's better to use native sql query?

    I've tried something like this one:
    public class PersonAndRepresentatives {
         private Person person;
         private List<Representative> representatives;
    //my query:
                    StringBuilder sb = new StringBuilder();
                 sb.append("select new model.stateless.helperobject.PersonAndRepresentatives(p, repr) from Person p, Representative repr");
              sb.append(" where repr.title like p.firstName and repr.title like p.lastName");
              sb.append(" group by person.id");
              List<PersonAndRepresentatives> resultList = em.createQuery(sb.toString()).getResultList();But of course, I get exception on "*,*" which is here: "*from Person p, Representative repr*".
    What can I do?
    Seems like it's better to write native query and do not try to solve the problem using JPQL.

  • Updatable report strange "Primary Key Source" behaviour

    I have an updatable report based on a table with one primary key
    When I create the report and try to edit the last field to give it a default value, I get
    "Primary Key Source" while I should get the default option.
    The field in question isn't a primary or foreign key and can be NULL.
    Does anyone know why this is?

    The solution you're suggesting is the best in my oppinion as well, however, I would like to know if it's possible to resolve this issue in another way. Using technical key's is best practice, but it's not wrong if you don't... so why isn't there a way in APEX to handle this?
    Maybe using the "Primary Key Source Type" as "Custom PL/SQL Function" in the "Tabular Form Element" is a possibility?
    I will try to convince the customer (other IT department) to use a technical primary key and replace the user generated key by a unique constraint, but ... I just want to know :)
    Edited by: Voxie2 on Jan 7, 2010 2:30 PM

  • How to speed up fast refresh of materialized view without primary key

    Thought I'd share this info, as I couldn't find anything on here to help me diagnose the issue:
    I had a materialized view that was taking longer to perform a fast refresh than it took to perform a complete refresh. My mview had no primary key, as the base table had no primary key.
    I created a trace file for the session and saw references to a column M_ROW$$ in my mview. Nowhere in the data dictionary could I find a reference to the m_row$$ column in my mview, but apparently it exists and is created automatically. After creating the index below, the fast refresh took 6 minutes to add 500k rows to the materialized view. (versus 4+ hours without the index) When I looked in the trace file, I noticed that for each row in the mview log, it first tries to update the mview with an UPDATE statement, then it performs an insert of the new data. Seems like it should be able to determine whether to perform an update or insert based on the DMLTYPE$$ column of the mview log. What was killing my performance was the UPDATE phase. Since I had no primary key on the mview, and no index on the m_row$$ column, the UPDATE phase was performing a full table scan of my mview for every row in the mview log. I was expecting it to be smart enough to only perform inserts, as the only transactions against the base table were inserts.
    In summary: If you have a materialized view without a primary key, create an index on the m_row$$ column of the mview, even though no such column displays in the data dictionary.
    ex:
    CREATE MATERIALIZED VIEW mv_minidrr ...
    CREATE INDEX pk_mv_minidrr ON mv_minidrr(m_row$$) ...

    Well, there indeed is a column called M_ROW$$
    Your MLOG$_EMP is nothing but the materialized view log on the base table.
    SQL> create  materialized view log on emp with rowid ;
    Materialized view log created.
    SQL> create materialized view emp_mview refresh fast on demand with rowid as select * from emp ;
    Materialized view created.
    SQL> desc mlog$_emp
    Name                                                  Null?    Type
    M_ROW$$                                                        VARCHAR2(255)
    SNAPTIME$$                                                     DATE
    DMLTYPE$$                                                      VARCHAR2(1)
    OLD_NEW$$                                                      VARCHAR2(1)
    CHANGE_VECTOR$$                                                RAW(255)
    SQL> select table_name, column_name from user_tab_columns where column_name = 'M_ROW$$' ;
    TABLE_NAME                     COLUMN_NAME
    MLOG$_EMP                      M_ROW$$
    1 row selected.
    SQL>

  • Automatic row processing updating my primary key

    Hi all!
    In Apex 3.2, I've got an Interactive report with a DML form on a table. My table has a primary key which use a sequence (trigger based). When I created my forms, I specified that I wanted to use an existing trigger as the source type of the primary key.
    When I try to create a record, it work. If I try to create a new record and save, my trigger give me an error message because the automatic row processing is trying to update the primary key too. (My trigger on the update specify that the primary key should not be updated).
    So my question is : How can I make the automatic row processing update everything but the primary key ? (I noticed that I could have asked APEX to use my SEQUENCE directly instead of the trigger (in the creation Wizard). But I dont know how to change this now that my form is created.)
    Is there a source type that I can change in my primary key item ?
    Note : My primary key item (id_emp) is protected and hidden. If I display it as "Display only", the update works... But I dont need to see id_emp on my form.

    OK,
    From your first post, it sounds as though the process is trying to perform an INSERT rather than an UPDATE. It is, therefore, trying to create a new record using a primary key that already exists on the table.
    If that is the case, then we need to go through the points along that route:
    1 - when you load a record into the page, the primary key page item should be given a value. So, firstly, check the link is populating the correct page item. And then, when the page has loaded, click the Session button on the Developer's toolbar at the bottom of the screen and check that the value is there
    2 - when the page loads, one, and only one, page item should have the primary key value. This should be P3_NO_EMPLOYE*. Check other page items to make sure that their source is not NO_EMPLOYE. Again, check with using the Session button to see if the value appears anywhere else on the page
    3 - when the page loads, the "SAVE" button should become visible. Check that this is conditional on P3_NO_EMPLOYE being NOT NULL
    4 - there should be one, and only one, button that triggers the SAVE action. Check that there are no other buttons that either (A) are called SAVE or (B) trigger the INSERT SQL database action
    5 - when the SAVE button is clicked, the "Process Row of..." process should be triggered and, because the button is SAVE and, therefore, sends "SAVE" as the REQUEST value, the process identifies this request as an Update database action. Check that you have Update ticked on the process and that you only have one process that can perform the update
    6 - it is possible to change the value of the Request after a button has been clicked, so check that you have no computations or processes that run before the "Process Row of..." process
    Andy

  • Creating a snapshot without primary keys

    Hi,
    I would like to create a snapshot for a table that does not have a primary key. I've read the thread
    "Re: creating snapshots without a primary key??"
    from Mar 24, 2003, which seems to indicate that this is allowed if the snapshot is not updatable. However, even when I disable the "Updatable?" option, I still get the following error:
    WTG-20502 Packaging Wizard Failed. 500
    CONS-10032: Publication item: WTGPI_10012 cannot
    be updatable, primary keys for xyz.abc not found.
    BTW, the Oracle9i Lite Developer's Guide for Windows 32 is really thin in this area. In particular, the description of the Updatable feature is the following:
    This check box defines the snapshot to be created
    as updatable.
    That description has a lot of unmet potential.
    Thanks,
    Tim

    Hello,
    If you create a snapshot that has no primary key, you have to check the option "complete refresh".
    Oracle uses the primary key to track changes for the "partial refresh" option (only send changes back and forth).
    -Antti Virkkunen, www.vilant.com

  • Who can I update primary key field in master block

    Hi,
    I want to update the primary key field in master block when there are some records are present in detail block, when I edit the primary key filed there is an error FRM-40509 unable to update record. The primary key is also referred by the detail table.
    So kindly give me the solution who can I update the primary key in master block when there is child records exists in detail block?.
    Best regard,
    shahzad

    pls tell us a little more about, why you want to update a PK in a master block.
    I haven't done that my whole time. Maybe you need something different.
    The problem is, that your child-data references to the master-pk, so there is the point you have to go deep into the codings. But better don't do it. Tell us first why. I think there are other solutions for that.
    try it
    Gerd

  • CDC without Primary Key

    Hi,
    Can we implement Change Data Capture in Oracle 10g without having Primary Key at the source level.
    With Regards,
    Katta

    Hi;
    Can we implement Change Data Capture in Oracle 10g without having Primary Key at the source level.AFAIK yes; Please see
    http://docs.oracle.com/cd/B13789_01/server.101/b10736/cdc.htm#i1025409
    http://en.wikipedia.org/wiki/Change_data_capture
    Regard
    Helios

Maybe you are looking for