Primary Key Error

I imported some tables from a CSV file. When I imported, I chose to use the original Primary Key and generated a new sequence for the primary key's trigger. Now, Whenever I use the forms to add a new record to the table, I get the following error message:
ORA-00001: unique constraint (MOBILE_INV.TBL_NEXTELPHONE_PK) violated
What should I do?
Is there something wrong with the trigger?
reate or replace trigger "bi_TBL_NEXTELPHONE"
before insert on "TBL_NEXTELPHONE"
for each row
begin
if :new."PHONEID" is null then
select "TBL_NEXTELPHONE_SEQ".nextval into :new."PHONEID" from dual;
end if;
end;
Is there something wrong with the sequence? (Here's my current sequence)
Min Value 1
Max Value 999999999999999999999999999
Increment By 1
Cycle Flag N
Order Flag N
Cache Size 20
Last Number 21

Hello,
It looks like you already had some records in your table before you created the sequence and triggers. Recreate the sequence and use as Min value the value +1 of the max in your table.
Regards,
Dimitri
-- http://dgielis.blogspot.com/
-- http://apex-evangelists.com/
-- http://apexblogs.info/

Similar Messages

  • Application Translation Not Working - Primary Key Error

    I had created an application translation to Spanish but it wasn't displaying my Spanish translation. I was going to try and redo it so I tried creating a new mapping and then seeding the translatable text. I got a primary key error "ORA-20001: Seed insert error: WWV_FLOW_TOPLEVEL_TABS.TAB_TEXT ORA-00001: unique constraint (FLOWS_030100.WWV_FLOW_TRANSLATABLE_TEXT_PK) violated".
    I went in and deleted what I had done through APEX for this app and tried to create a new application but still get the primary key error when I try to seed it. I gave it a new translated application ID but that doesn't seem to help. Anyone have this problem or no of the reason I'm having this issue?
    Thanks.

    Hi David,
    Thanks for reporting this. This was an interesting problem to solve.
    As it turns out, it was a logic error in Application Express (i.e., bug). When deleting a translation mapping, the associated strings in the translation repository would be deleted for that application, but if and only if you had actually published the application.
    I think this is why you could never get Spanish working properly - you had never actually published the application the first time. So I'll bet what you did is deleted the original mapping, then you recreated the mapping for the same language but with a different translated application ID. Since you had never published the application from the original translation mapping, and there were orphaned rows in the translation repository, you encountered a "collision" when you tried to seed the second time with the different translated application ID.
    Your action of deleting rows from WWV_FLOW_TRANSLATABLE_TEXT$ cleaned up these orphaned rows. As you stated, this isn't recommended to perform DML on the underlying APEX tables. A couple alternatives could have been:
    1) Before deleting the translated application mapping, actually publish the application and then delete the mapping.
    2) If you had deleted the mapping already, you could recreate the mapping for the same language and with the original translated application ID. Then, publish the application and then go back and delete the mapping.
    I realize all this sounds crazy. But it was only an issue because you had not actually published the application. Not your fault, though, as this is a bug in APEX.
    This bug will be fixed in Application Express 4.0. This way, you won't have to worry about if you published or didn't publish. The orphaned rows will be cleaned up when you delete a mapping.
    Thanks again for reporting this.
    Joel

  • Oracle Primary key error on a sequence number generator

    I have a table called table 1 and I am trying to insert a few values in this table and i am constantly getting bogged down by a primary key error. Strange thing is this primary key called "ID" on the table is a sytem generated sequence value number. The error is
    "ORA-00001: unique constraint (Schema1.LICN_PK) violated"
    Any idea?
    I will post the structure of the table below and my SQL statement as well.
    Table structure:
    CREATE TABLE schema1.table1
    ID NUMBER(12),
    LITM_ID NUMBER(12),
    PROG_PROGRAM_CD VARCHAR2(2 BYTE),
    SCHED_NBR VARCHAR2(3 BYTE),
    SCHD_VERSION_YR NUMBER(4),
    SCHD_VERSION_NBR NUMBER(3),
    LITM_LINE_ITEM_NBR VARCHAR2(3 BYTE),
    SLIN_LINE_ITEM_ID NUMBER(12),
    COND_CD VARCHAR2(15 BYTE),
    COND_TYPE VARCHAR2(1 BYTE) DEFAULT 'O',
    COND_TEXT VARCHAR2(240 BYTE),
    DERIVE_COMPRSN_IND VARCHAR2(1 BYTE),
    DISPLAY_SEQ_NBR NUMBER(5),
    SEVRTY_CD VARCHAR2(1 BYTE),
    OVRRDBL_IND VARCHAR2(1 BYTE),
    NEVER_OVRRDBL_IND VARCHAR2(1 BYTE),
    CREATED_BY VARCHAR2(8 BYTE),
    CREATED_TMST DATE,
    MODIFIED_BY VARCHAR2(8 BYTE),
    MODIFIED_TMST DATE
    CREATE UNIQUE INDEX schema1.LICN_PK ON schema1.table1
    (ID)
    NOLOGGING
    TABLESPACE INDEX_STAT1
    PCTFREE 10
    INITRANS 2
    MAXTRANS 255
    STORAGE (
    INITIAL 128K
    NEXT 128K
    MINEXTENTS 1
    MAXEXTENTS UNLIMITED
    PCTINCREASE 0
    BUFFER_POOL DEFAULT
    NOPARALLEL;
    CREATE UNIQUE INDEX schema1.LICN_UK ON schema1.table1
    (LITM_ID, COND_CD)
    NOLOGGING
    TABLESPACE INDEX_STAT1
    PCTFREE 10
    INITRANS 2
    MAXTRANS 255
    STORAGE (
    INITIAL 128K
    NEXT 128K
    MINEXTENTS 1
    MAXEXTENTS UNLIMITED
    PCTINCREASE 0
    BUFFER_POOL DEFAULT
    NOPARALLEL;
    Table structure ends
    ****************Insert statement*************
    insert into table1
    (id,
    litm_id,
    prog_program_cd,
    sched_nbr,
    schd_version_yr,
    schd_version_nbr,
    litm_line_item_nbr,
    slin_line_item_id,
    cond_cd,
    cond_type,
    cond_text,
    derive_comprsn_ind,
    display_seq_nbr,
    sevrty_cd,
    ovrrdbl_ind,
    never_ovrrdbl_ind,
    created_by,
    created_tmst,
    modified_by,
    modified_tmst)
    values
    (LITM_ID_SQ.nextval,
    5678,
    '28',
    000,
    2005,
    1,
    '007',
    28,
    '0008',
    'E',
    'No advance',
    'N',
    80,
    'M',
    'N',
    'Y',
    USER,
    SYSDATE,
    USER,
    SYSDATE);
    *************End***********************
    Any idea why the error is coming up and any way to resolve it. I checked the max sequence number value and kept running it for a while and then tried to run my insert statement but no luck yet.
    Please help!!!

    Hi,
    Are you tring to do the same insert more than once?
    The sequence for ID will be generated and there will be no problem with that.
    But what about UNIQUE INDEX schema1.LICN_UK ON schema1.table1(LITM_ID, COND_CD)?
    you are trying to insert the same values again into those columns... and there is a unique index.
    Test your insert by dropping the unique index LICN_UK
    DROP INDEX schema1.LICN_UK;Now it will work. But if you need the uniqueness, you need to insert different values for those columns each time you insert.
    G.

  • Composite Primary Key Error

    I am using Sun One App Server PE8.
    I have a class with a composite primary key field. When I place the following method in my Home interface:
    public MyEjb findByPrimaryKey(MyEjbPrimaryKey pk) throws FinderException, RemoteException;I get the following error when deploying:
    ejbFindByPrimaryKey(EjbPrimaryKey) is already defined in MyEjb1368202910_ConcreteImpl
        public MyEjbPrimaryKey ejbFindByPrimaryKey (MyEjbPrimaryKey key)However, If i remove this method from the Home interface, i get the following error when running the verification tool:
    Error: No single arg findByPrimaryKey(PrimaryKeyClass) method was found in home interface class [ MyEjb ].However, I can still deploy the EAR successfully.
    Another related symptom of this problem, is if I include the following method in my Home interface:
    public MyEjb findByPrimaryKey(String pkField1, String pkField2) throws FinderException, RemoteException;And call this method, I get the following exception at runtime:
    java.rmi.RemoteException: Bean class for ejb [MyEjb] does not define a method corresponding to [Home] interface method [public abstract MyEjb MyEjbHome.findByPrimaryKey(java.lang.String,java
    .lang.String) throws javax.ejb.FinderException,java.rmi.RemoteException]I get these same problems with all EJB's that use composite keys. Has anyone else had this problem?
    Thanks
    toby

    This is a CMP bean, with no ejbFindByPrimaryKey in the Bean class. Below, i have included the Home interface and the Bean class (with unneccessary code removed)
    Thanks for looking at this for me.
    BEAN CLASS
    package lands.mc.bus.prod;
    import java.rmi.*;
    import java.util.*;
    import javax.ejb.*;
    public abstract class TopoMapBean implements EntityBean
      private EntityContext entity;
      public TopoMapBean()
      public void setEntityContext(EntityContext ctx)
        entity = ctx;
      public void unsetEntityContext()
        entity = null;
      public TopoMapPrimaryKey ejbCreate(String mapName, String mapNumber, String mnemonic,String edition, String scale)
      throws CreateException
        // call setters...
        return null;
      public void ejbPostCreate( String mapName,
                                                   String mapNumber,
                                             String mnemonic,
                                             String edition,
                                             String scale )
      removed set/get methods
      public void ejbStore() {}
      public void ejbLoad() {}
      public void ejbActivate() {}
      public void ejbPassivate() {}
      public void ejbRemove() {}
    }HOME INTERFACE
    package lands.mc.bus.prod;
    import java.rmi.*;
    import java.util.*;
    import javax.ejb.*;
    public interface TopoMapHome extends EJBHome
      public TopoMap create(String mapName,
                            String mapNumber,
                            String mnemonic,
                            String edition,
                            String scale
      throws CreateException, RemoteException;
      public TopoMap findByPrimaryKey(String mapNumber, String edition) throws FinderException, RemoteException;
    // doesnt deploy with this signature
    //  public TopoMap findByPrimaryKey(TopoMapPrimaryKey pkey) throws FinderException;
    // have to use this method instead of findByPrimaryKey(String, String) above
      public TopoMap findTopoMap(String mapNumber, String edition) throws FinderException, RemoteException;

  • ORA-02266: unique/primary keys - error while using Exchange Partition

    Hi All,
    While using EXCHANGE PARTITION statement as given below,
    ALTER TABLE SOURCE_TABLE EXCHANGE PARTITION PRT_EXCG_PRTN WITH TABLE TARGET_TABLE
    we are getting this error,
    ORA-02266: unique/primary keys in table referenced by enabled foreign keys
    However, there are no tables have foreign keys referring this TARGET_TABLE, we checked this by referring
    USER_CONSTRAINTS table, it has only primary key and NOT NULL constraints.
    SELECT * FROM USER_CONSTRAINTS WHERE TABLE_NAME like 'TARGET_TABLE';
    We are using the following version,
    Oracle9i Enterprise Edition Release 9.2.0.6.0 - 64bit Production
    PL/SQL Release 9.2.0.6.0 - Production
    CORE     9.2.0.6.0     Production
    TNS for IBM/AIX RISC System/6000: Version 9.2.0.6.0 - Production
    NLSRTL Version 9.2.0.6.0 - Production
    Is it due to any error in our end or it could be a bug in Oracle and should we go for any patch updation ?
    Please guide us to resolve this error as soon as possible, thank you.
    Regards,
    Deva

    *** Duplicate Post ***
    Please Ignore.

  • Too many objects match the primary key error

    Hi
    I have a detail table with a primary key consisting of 3 fields. I add a new row to the table and it is OK but when I try to add another record to the table it says that
    JBO-25013: Too many objects match the primary key oracle.jbo.Key[null 123 null]. I want to add two or more rows to the table at once and after that I fill the rows and submit the form. What should I do?
    Anyway, I am using JDev 11.1.1.4
    Thanks
    Ferez

    Hi ADF 7(!),
    Many thanks for the links. My problem is exactly the same problem mentioned by user5108636 at the bottom of the thread which is not answered yet, i.e.,
    "How do I prevent the multiple PK with null, if the user just keeps click 'CreateInsert' after 'CreateInsert' "
    Is it possible to defer the primary key validation to commit time? I don't know why the framework checks for the unique key constraint immediately after inserting the row and before committing it (I have created a new thread for this here: How to defer the primary key validation to commit time
    Maybe a workaround such as disabling the create button after pressing it and re-enabling it again after commit or rollback would work, but I do not want prohibit the user from creating multiple new rows at once, filling them all together, and committing them at the same time.
    Thanks,
    Ferez

  • Table creation from type - Primary key with 2 columns

    Hello,
    I have to create a table from a type that I created.
    The thing is that I want to create a primary key using two column.
    Because this table is junction table.
    How can I do this ?
    CREATE TABLE CONTENT OF CONTENT_T (ID_COMP primary key, ID_CHAR_J NOT NULL PRIMAR
    Y KEY);
    Oracle return:
    CREATE TABLE CONTENT OF CONTENT_T (ID_COMP primary key,ID_CHAR_J NOT NULL PRIMARY KEY)
    ERROR at line 1:
    ORA-02260: table can have only one primary key
    So I tried:
    CREATE TABLE CONTENT OF CONTENT_T (ID_COMP,ID_CHAR_J NOT NULL PRIMARY KEY)
    ERROR at line 1:
    ORA-02338: missing or invalid column constraint specification
    Tahnk's in advance.
    Edited by: user8266437 on 29 avr. 2009 13:56
    Edited by: user8266437 on 29 avr. 2009 13:56

    SCOTT@orcl_11g> CREATE OR REPLACE TYPE content_t AS OBJECT
      2    (id_comp    NUMBER,
      3       id_char_j  VARCHAR2 (10),
      4       other_cols VARCHAR2 (10));
      5  /
    Type created.
    SCOTT@orcl_11g> CREATE TABLE CONTENT OF CONTENT_T (PRIMARY KEY (ID_COMP, ID_CHAR_J))
      2  /
    Table created.
    SCOTT@orcl_11g> INSERT INTO content VALUES (content_t (1, 'A', 'WHATEVER'))
      2  /
    1 row created.
    SCOTT@orcl_11g> COMMIT
      2  /
    Commit complete.
    SCOTT@orcl_11g> INSERT INTO content VALUES (content_t (1, 'A', 'DUPLICATE'))
      2  /
    INSERT INTO content VALUES (content_t (1, 'A', 'DUPLICATE'))
    ERROR at line 1:
    ORA-00001: unique constraint (SCOTT.SYS_C0062057) violated
    SCOTT@orcl_11g> COMMIT
      2  /
    Commit complete.
    SCOTT@orcl_11g> SELECT * FROM content
      2  /
       ID_COMP ID_CHAR_J  OTHER_COLS
             1 A          WHATEVER
    SCOTT@orcl_11g>

  • How to handle duplicate Primary Key entries in the Source data

    This is my first experience with ODI.
    I receive Source data from the customer that includes a one letter designation, ACTION_CODE, in each record of data as to the disposition of the record:
    ‘R’ represents Re-issue in which case I’m to modify the corresponding Target record based on the Primary Key.
    ‘N’ represents an Insert in which case I’m to insert a new record into the Target.
    ‘D’ represents a delete in which case I’m to delete the record with the corresponding Primary Key from the Target.
    The Source data comes in an XML file and the Target is an Oracle DB.
    I have chosen the IKM Oracle Incremental Update (MERGE) Knowledge Module.
    I filter ACTION_CODE to just collect records that are ‘N’ or ‘R’ and I exclude the ACTION_CODE from the mapping but since within the same Source
    set there may be an ‘N’ and ‘R’ with the same primary key I receive Primary Key errors.
    Should I alter CKM to not check for duplicates in the Source?
    Is there a better way?

    Ganesh,
    Identifying Duplicates is a logical activity.  More or less it need Manual intervention to judge both the records means common.  if few unique paramenters like Telephone, Pincode, SSN, passport no etc can be used on filters for searching the records.  Currently there are no automatic method to identify the duplicates.  In MDM 5.5 SP04 which is next release there will be auto de-duplicate facility based on tresholeds and matching criteria that you will setup.
    I hope i have answered your query transparently. if you have any queries futher you can reply here.
    Regards
    Veera

  • Primary key foreign key dependencies

    hi gems...
    I have a table with composite primary key (COL1, COL2)..
    create table TABLE1 (COL1, COL2);
    alter table TABLE1 add constraint PK_TABLE1 primary key (COL1, COL2);
    Now i am trying to make another table which will refer to the COL1 of the first table.
    create table TABLE2 (COL3, COL4);
    alter table TABLE2 add constarint FK_TABLE2 (COL3) references TABLE1(COL1);
    but it is failing with "no matching unique or primary key" error.

    You have created a composite primary key, so there must be composite foreign key that references the composite primary key. You cannot create Foreign key that references to single column of the composite primary key.

  • Capture & override JBO-25013 too many object objects match the primary key

    Hi
    Does anybody know how to override the default primary key errors raised by JDev?
    Under ADF BC and UIX, currently when a user creates a new record and attempt to save it where the PK values supplied already exist, the following 2 error messages are displayed:
    JBO-25013: Too many objects match the primary key oracle.jbo.Key[xx xx ].
    JBO-27024: Failed to validate a row with key oracle.jbo.Key[xx xx ] of type yyyyy
    Where xx are parts of my PK, and yyyyy is my table.
    What I'd like to do is replace these 2 error messages with a single, different error message.
    On the underlying EO I can capture JBO-27024 error message in the validateEntity method, but can't override nor stop the JBO-25013 message. I need to capture both and only show my alternative message.
    Any idea how to do this?
    Thanks & regards,
    CM.
    PS. JDev 10.1.2

    Boing X 3 :)
    Chris you got a solution for this ?

  • Modify a primary key constraint

    Hi,
    I'm starting with oracle, and I have two doubts that can't handle after searching on the internet.
    1º It's possible to make an ALTER TABLE of a CONSTRAINT DEFAULT?. Maybe you think that the question should be in another way like this: Does oracle database take the default condition as a constraint?. As long as I know, doesn't do that.
    2º It's possible, with an ALTER TABLE, to MODIFY a CONSTRAINT of a PRIMARY KEY, to add another more field?
    I've been searching on the internet, but I didn't find a clear answer. I'm using oracle 10g express edition.
    Thank you very much.
    P.D.:Sorry for my english it's not very good.

    #2 - You can not 'add a column to the primary-key constraint of a table' with a single ALTER, but you can drop and re-create the primary key constraint (including the additional column).
    13:25:26> create table t1 (a number primary key, b number, c number );
    Table created.
    Elapsed: 00:00:00.09
    13:25:46> alter table t1 drop primary key;
    Table altered.
    Elapsed: 00:00:00.06
    13:25:47> alter table t1 add primary key (a,b);
    Table altered.
    Elapsed: 00:00:00.09But you will not be able to drop the primary key of an index-organized table.
    13:25:47> create table t2 (a number primary key, b number, c number ) organization index;
    Table created.
    Elapsed: 00:00:00.03
    13:25:59> alter table t2 drop primary key;
    alter table t2 drop primary key
    ERROR at line 1:
    ORA-25188: cannot drop/disable/defer the primary key constraint for
    index-organized tables or sorted hash cluster
    Elapsed: 00:00:00.00
    13:25:59> #1 - I'm not sure I understand your question , but you can alter a table's column to have a default. This is not a 'constraint', but a default. It only has effect when you perform an insert which does not include that column.
    13:31:23> alter table t1 modify (c default 3.14);
    Table altered.
    Elapsed: 00:00:00.04
    13:31:24> insert into t1 (a,b,c) values (1,2,3);
    1 row created.
    Elapsed: 00:00:00.01
    13:31:24> insert into t1 (a,b,c) values (4,5,NULL);
    1 row created.
    Elapsed: 00:00:00.00
    13:31:24> insert into t1 (a,b) values(6,7);
    1 row created.
    Elapsed: 00:00:00.01
    13:31:24> select * from t1;
             A          B          C
             1          2          3
             4          5
             6          7       3.14
    3 rows selected.
    Elapsed: 00:00:00.18

  • Error While Deploying A CMP Entity Bean With A Composite Primary Key

    Hello all,
    I have a problem deploying CMP Entity beans with composite primary keys. I have a CMP Entity Bean, which contains a composite primary key composed of two local stubs. If you know more about this please respond to my post on the EJB forum (subject: CMP Bean Local Stub as a Field of a Primary Key Class).
    In the mean time, can you please tell me what following error message means and how to resolve it? From what I understand it might be a problem with Sun ONE AS 7, but I would like to make sure it's not me doing something wrong.
    [05/Jan/2005:12:49:03] WARNING ( 1896):      Validation error in bean CustomerSubscription: The type of non-static field customer of the key class
    test.subscription.CustomerSubscriptionCMP_1530383317_JDOState$Oid must be primitive or must implement java.io.Serializable.
         Update the type of the key class field.
         Warning: All primary key columns in primary table CustomerSubscription of the bean corresponding to the generated class test.subscription.CustomerSubscriptionCMP_1530383317_JDOState must be mapped to key fields.
         Map the following primary key columns to key fields: CustomerSubscription.CustomerEmail,CustomerSubscription.SubscriptionType. If you already have fields mapped to these columns, verify that they are key fields.Is it enough that a primary key class be serializable or all fields have to implement Serializable or be a primitive?
    Please let me know if you need more information to answer my question.
    Thanks.
    Nikola

    Hi Nikola,
    There are several problems with your CMP bean.
    1. Fields of a Primary Key Class must be a subset of CMP fields, so yes, they must be either a primitive or a Serializable type.
    2. Sun Application Server does not support Primary Key fields of an arbitrary Serializable type (i.e. those that will be stored
    as BLOB in the database), but only primitives, Java wrappers, String, and Date/Time types.
    Do you try to use stubs instead of relationships or for some other reason?
    If it's the former - look at the CMR fields.
    If it's the latter, I suggest to store these fields as regular CMP fields and use some other value as the PK. If you prefer that
    the CMP container generates the PK values, use the Unknown
    PrimaryKey feature.
    Regards,
    -marina

  • Error with Links if using x3 primary keys

    Hi Folks:
    Here is the error code I'm receiving:
    ORA-01422: exact fetch returns more than requested number of rows
    Unable to fetch row.
    Background: I am using Application Express 3.2
    All of the pages I have created that rely on x2 primary keys (first_name, last_name) work fine.
    I have a table that has x3 primary keys: Table is called "time_off_awards". The x3 primary keys are: last_name, first_name, approval_date.
    I created a report that works properly and lists the awards for each person (each person can receive more than one award-on different dates).
    I also created an edit link that works properly IF *(only if)* each individual has only one award. If the individual has more than one award then I get the error above. When I set up the link I used all three keys. The x3 PK's should uniquely identify each row, but if the same last name/first name appear more than once (that is if the person has more than one award) I get the error. I thought at first maybe it was just not reading the 3rd key/part of the link (approval_date), but it shows properly if you move your cursor over the edit link.
    Here is a link to a screen pic of how I have my link set in Apex:
    [http://www.wczone.com/link_settings.gif]
    Here is a link to a pic of the report with some info:
    [http://www.wczone.com/report_link.gif]
    If needed, here is my table info:
    CREATE TABLE PERSONNEL.TIME_OFF_AWARDS (
    LAST_NAME VARCHAR2(40) NOT NULL,
    FIRST_NAME VARCHAR2(25) NOT NULL,
    APPROVAL_DATE DATE NOT NULL,
    HOURS_OFF NUMBER(3),
    CITATION VARCHAR2(1500),
    /* Keys */
    PRIMARY KEY (LAST_NAME, FIRST_NAME, APPROVAL_DATE),
    /* Foreign keys */
    CONSTRAINT TOA_PERSONNEL
    FOREIGN KEY (LAST_NAME, FIRST_NAME)
    REFERENCES PERSONNEL.MARC_PERSONNEL(LAST_NAME, FIRST_NAME)
    TABLESPACE PERSONNEL;
    Thanks for any help, I've tried looking at a couple of Apex books, but they didn't help much.
    Matt
    Edited by: user10495310 on Mar 4, 2009 8:21 AM

    Thank you everyone for the help and information you gave to me.
    Your ideas and advice helped me to think through the issues involved.
    The way i actually found to work around this issue was a little different.
    What I did was the following (which may only be usable with empty tables. If its possible to create a new column with a sequence and trigger on a table that already contains data it should work also):
    1. I removed the current PK's that were currently set.
    2. I added a single, unique PK (that used a sequence and trigger to automatically increment) to the table as was suggested in this thread and other APEX forum threads.
    3. I changed the link on the report so that it used the new PK, and also changed the PK used on the forms (under Processes - both the page rendering and page processing processes).
    The Difference:
    4. Next I changed the table (not by using APEX, but directly) from using the automatically generated ID as the PK, back to using the compound PK (x3 keys). I then added an constraint to make sure that the automatically generated column was unique. So now I have the compound PK that my supervisor wants us to use, and I'm able to use a unique, automatically generated key for APEX to use.
    I found also that if you already have a column that uses a unique/auto-generated key you can still use it with APEX without switching keys around.
    1. I added the new column to the sql in the reports source section so that the new column was searched (and then used 'hidden' so it wouldn't be displayed on the report users would see).
    2. You can still add the unique key under the processes on the form that is being linked too under the Primary key tabs. If its not a PK it won't show up in the pop up which is to the right of "Item Containing Primary Key Column Value" but it can be entered manually (i.e. p23_AUTO_ID) and it will work fine. You would also need to edit your form so that the auto ID that is being passed from the report is part of the form - but hidden if desired).

  • Getting error message when passing data into table: Primary Key

    Getting an error in a process that is feeding the invoice creation in SAP, violation of PRIMARY KEY constraint 'INV1_Primary', cannot insert duplicate key in object 'INV1'. I assume this is due to duplicate key values being passed into the table INV1, however I get this error even when I am passing unique record combinations of the key fields docentry and linenum. This is on 2005A SP01.
    Thanks

    Hi Peter,
    Could you provide a code sample of the routine that is causing the error please?
    It sounds like a data corruption issue (though it could possibly be a bug in the DI API). I recommend you speak to SAP support. There is a utility that can validate the document numbering but you'll need to speak to SAP support before you run this as it can have other negative effects, depending on the state of your data. They may ask for a copy of your database to test.
    Kind Regards,
    Owen

  • Error while creating the Unique Index of the Primary Key of an Item

    Hi all,
    I have deployed a new item (CO_CONTRACTUNIT_PRODUCT) in my publication. The deploy appears to be successfull as the item can be seen in the repository through the Mobile Manager.
    The problem occurs when i sync my local DB to get the item offline. While synchronizing, the following error appears, both in the sync window and the log file ol_sync.log.
    "ERROR",POL-5130,"11/09/2010 11:43:52","table or view %s.%s not found:CO_CONTRACTUNIT_PRODUCT,CO_CONTRACTID,OD_PRODUCTID,CO_CONTRACTUNITID","DB_ROSHNI"
    However, the debug file gives this other error regarding this table.
    ALL_INDEX:CREATE UNIQUE INDEX "TPCO_CONTRACTUNIT_PRODUCT_PK" ON CO_CONTRACTUNIT_PRODUCT (CO_CONTRACTID,OD_PRODUCTID,CO_CONTRACTUNITID) -5130Error at C:\ADE\omeprod_ol103021\olite\db\build\win\ocapi\..\..\..\src\ocapi\allindexes.cpp line:329 rc:-5130
    Build date Mar 29 2010
    okErr=(table or view %s.%s not found)
    mess=(CO_CONTRACTUNIT_PRODUCT,CO_CONTRACTID,OD_PRODUCTID,CO_CONTRACTUNITID)
    AddLog(-5130 "ERROR",POL-5130,"11/09/2010 11:43:52","table or view %s.%s not found:CO_CONTRACTUNIT_PRODUCT,CO_CONTRACTID,OD_PRODUCTID,CO_CONTRACTUNITID","DB_ROSHNI")
    But the index that is being created and is giving the error is the index created automatically with the Primary Key of the table, and so nothing has been modified in that.
    The primary key of the table is created with the three columns that are part of the index that is returning the error.
    As I could not solve the error, I tried to drop and re-create the item in the repository, but no luck. As a last option, i tried to remove the item from the repository to be able to sync properly again (just like before creating the item), but the error still happens.
    Another weird point is that i have tried creating the item in another publication of another database (but with almost equal items), and the item could was downloaded to my local DB without any problem, which makes this problem still more bizarre.
    What can it be?
    Any help would be great!
    Roshni

    have you tried unistalling the client and reinstalling it?
    schema evolution changes are not always handled correctly please check thread:
    Modification of publication item into Mobile Server
    i quote from rekounas instructions:
    If you are just adding a field, you should only have to run the alter publication item API call.
    Here is an old note on schema evolution on different scenarios. The names for the APIs that they use are now deprecated. Use the ConsolidatorManager class and call the method alterPublicationItem("PUBLICATION_ITEM_NAME", "SELECT STMT") :
    A) Add column
    1. Upload all client data. Clients should not add new data until they are told by the administrator to sync again!!
    2. Stop Mobile Server listener
    3. Change the Oracle8i/9i database schema (add column)
    4. Create a Java program to call the Consolidator Admin API AlterPublicationItem()
    5. Start Mobile Server
    6. Execute a sync from the client
    7. The new column should be seen on the client. Use MSQL to check snapshot definitions.
    B) Drop column
    1. Upload all client data. Clients should not add new data until they are told by the administrator to sync again!!
    2. Stop Mobile Server listener
    3. Delete column of the base table in the Oracle database schema
    4. Create a Java program to call the Consolidator Admin API DropPublicationItem()
    5. Create a Java program to call the Consolidator Admin API CreatePublicationItem() and AddPublicationItem().
    6. Start Mobile Server
    7. Execute a sync from the client
    8. The new column should be seen on the cliet. Use MSQL to check snapshot definitions.
    C) Change column datatype
    Changing datatypes in a repliatated system is not an easy task. You have to follow certain procedures in order to make it to work. Use DropPublicationItem, CreatePublicationItem and AddPublicationItem methods from the Consolidator Admin API. You must stop/start Mobile Server listener to refresh the cache.
    1. Client syncs. Clients should not add new data until they are told by the administrator to sync again!!
    2. Stop Mobile Server listener
    3. Drop/create column (do not use conversion procudures) at the base table
    4. Call DropPublicationItem(). Check if the ErrorQueue and InQueue no longer exist.
    5. Call CreatePublicationItem() and AddPublicationItem(). Check if the ErrorQueue and InQueue reflect the new column datatype
    6. Start Mobile Server. This automatically resumes application
    7. Client executes sync. This should drop the old snapshot and recreate the new snapshot. Use MSQL to check
    snapshot definitions.
    D) Drop table
    1. Client syncs. Clients should not add new data until they are told by the administrator to sync again!!
    2. Stop Mobile Server listener
    3. Drop base table
    4. Call DropPublicationItem(). Check if the ErrorQueue and InQueue no longer exist.
    5. Start Mobile Server. This automatically resumes application
    6. Client executes sync. This should drop the old snapshot. Use MSQL to check snapshot definitions.
    E) Add table
    1. Client syncs. Clients should not add new data until they are told by the administrator to sync again!!
    2. Stop Mobile Server listener
    3. Add new base table
    4. Call CreatePublicationItem() and AddPublicationItem() method
    5. Start Mobile Server. This automatically resumes application
    6. Client executes sync. This should add the new snapshot. Use MSQL to check snapshot definitions.
    F) Changing Primary Keys
    Chaning PK is a severe operation which must be executed manually. A snapshot must be deleted and recreated to propagate the changes to the clients. This causes a full refresh on this snapshot.
    1. Client syncs. Clients should not add new data until they are told by the administrator to sync again!!
    2. Stop Mobile Server listener
    3. Drop the snapshot using DropPublicationItem() method o
    4. Alter the base table
    5. Call CreatePublicationItem()and AddPublicationItem() methods for the altered table
    6. Start Mobile Server. This automatically resumes application
    7. Client executes sync. The old snapshot will be replaced by the new snapstot using a full refresh. Use MSQL to check snapshot definitions.
    G) To Change a Table Weight =>
    Follow the procedure below to change the Table Weight parameter. The table weight is used by the Mobile Server/Synchronization to determin the sequence in which client records are applied to the Oracle database.
    1. Run MGP to apply any changes in the InQueue to the Oracle databse
    2. Change table weight using SetTemplateItemMetadata() method
    3. Add/change constraint on the the base table which reflects the change in table weight
    4. Synchronize
    gl m8

Maybe you are looking for