Primary key violation exception in auto increment column

Hi All,
I am facing one issue in Multi threaded environment.
I am getting Primary key violation exception in auto increment column. I have a table and the primary key is the auto increment column, and I have a trigger which is populating this column.
5 threads are running and inserting the data in the table and throwing Primary key violation exception randomly.
create table example (
id number not null,
name varchar2(30)
alter table example
add constraint PK1example primary key (id);
create sequence example_id_seq start with 1 increment by 1;
create or replace trigger example_insert
before insert on example
for each row
begin
select example_id_seq.nextval into :new.id from dual;
end;
Any idea how to handle auto increment column(trigger) in Multi threaded environment??
Thanks,

user13566109 wrote:
Thanks All,
Problem was in approach; removed the trigger and placed a seq.nextval in insert query. It has resolved the issue.I very much suspect that that was not the issue.
The trigger would execute for each insertion and the nextval would have been unique for each insertion (that's how sequences work in oracle), so that wouldn't have been causing duplicates.
I suspect, more likely, that you had some other code somewhere that was using another sequence or some other method of generating the keys that was also inserting into the same table, so there was a conflict in the sources of the sequences being generated.
The way you showed you had coded above, was a perfectly normal way to assign primary keys from a sequence, and is not a problem in a multi user/threaded environment.

Similar Messages

  • SET NOCOUNTON causing Primary key violation exception from client code

    Hi,
    We have a stored procedure in SQL Server - 2012 which contains two insert statements as below      
    BEGIN   
    SET NOCOUNT ON;        
     if(@Status ='1')      
      Begin      
     insert into dcmnt_mstr       
      (trn_id,sub_no,usr_id,ref_id,email_id,reg_no,ordrd_date,ordr_cust_ref,email_status,chrg_status,upd_user,row_created_by)      
      values(@TranId,@SubsriberNo,@UserId,@RefId,@EmailId,'00000000',getdate(),@RefText,'0','0','Bulk Order',@AppId)      
      end      
     insert into dcmnt_bulk       
    (trn_id,reg_no,pkg_type,proc_status,upd_user)      
    values       
    (@TranId,@RegNo,@PkgType,'0','Bulk Order')      
    END 
    By using the SSMS2012 query analyzer we are able execute this SP successfully.
    But when this is executed from client code[Java Code] we are getting an error like below
    com.jnetdirect.jsql.x: Violation of PRIMARY KEY constraint 'PK_dcmnt_mstr'. 
    Cannot insert duplicate key in object 'dbo.dcmnt_mstr'. The duplicate key value is (5421e73993b46c15).
    The same is working fine from the client code once the statement SET NOCOUNT ON; is removed from the SP.
    Could some one can help to identify the root cause?
    Thank you

    It looks like the application code is examining the row count returned and retrying the insert if less than 1.  So you need to either specify SET NOCOUNT OFF (the default) or change the app code.
    Dan Guzman, SQL Server MVP, http://www.dbdelta.com

  • Auto Increment column query

    I have a very simple table used for debugging:
    CREATE TABLE APPS.XX_DEBUG_TMP
      TEMP_VALUE  VARCHAR2(255 BYTE),
      TEMP_DATE   DATE
    )Then I can use it to store values as my pl/sql is processed - e.g.:
    INSERT INTO XX_DEBUG_TMP (TEMP_VALUE,TEMP_DATE) VALUES ('line 740 l_username value check:' || l_username,SYSDATE);  COMMIT;Trouble is that if a load of debug statements get processed with the same timestamp, I can't see which came first.
    Can I modify my table creation SQL to include an ID column which just increments for each row that is added to the table?
    I'm familiar with how to do it in MySQL (sorry - I know this is an Oracle forum - but am just putting this here to show what I mean):
    CREATE TABLE  `XX_DEBUG_TMP` (
    `TEMP_ID` MEDIUMINT( 10 ) NOT NULL AUTO_INCREMENT PRIMARY KEY ,
    `TEMP_VALUE` VARCHAR( 255 ) NOT NULL ,
    `TEMP_DATE` DATETIME NOT NULL
    ) ENGINE = MYISAM ;Is it that simple with Oracle? Probably not!
    Any advice much appreciated.
    Thanks

    There is no auto increment column in Oracle. However, you can create a sequence.
    CREATE TABLE APPS.XX_DEBUG_TMP
      TEMP_ID     NUMBER NOT NULL PRIMARY KEY,
      TEMP_VALUE  VARCHAR2(255 BYTE),
      TEMP_DATE   DATE
    CREATE SEQUENCE APPS.XX_DEBUG_TMP_SEQ;Then in your insert statement do this:
    INSERT INTO XX_DEBUG_TMP (TEMP_ID,TEMP_VALUE,TEMP_DATE) VALUES (APPS.XX_DEBUG_TMP_SEQ.NEXTVAL,'line 740 l_username value check:' || l_username,SYSDATE);  Another possible solution to your problem would be to use a TIMESTAMP data type instead of a DATE data type. It has fractional second resolution (up to 9 places I believe).

  • Can we specify prefix for an auto increment column

    Hi all,
    I want to create an auto increment column in oracle using oracle sequences.
    But i want to specify a prefix for the value appearing after increment.
    Prefix will remain constant.
    If we can how can i do that.
    And one more thing is i will call the sequence using a trigger only for a specified condition.My doubt here is can i allow nulls for auto incrementing column
    With Regards

    <s></s>
    -- Samples.
    create table tab1
    (id   varchar2(6) constraint p_tab1 primary key
    ,data varchar2(255)
    create sequence seq_tab1;
    create or replace
    trigger trg_tab1
    before insert on tab1
    for each row
    declare
      p_prefix varchar2(2) := 'AA';
    begin
      if (:new.id is null) then
        select p_prefix||to_char(seq_tab1.nextval,'fm0009') into :new.id from dual;
      end if;
    end
    -- Test
    SQL> insert into tab1(data) values('abc');
    1 row created.
    SQL> insert into tab1(id,data) values('BB9999','xyz');
    1 row created.
    SQL> select * from tab1;
    ID
    DATA
    AA0001
    abc
    BB9999
    xyz

  • Add auto increment column to trigger

    I want to add auto increment column to after insert trigger. so how can I do that?

    this is my query.
    Create Sequence Up_Seq
    Start With 1
    Increment By 1
    nomaxvalue;
    Create Or Replace Trigger Upf_Trig
    After Insert On members
    Referencing New As New
    For Each Row
    Begin
    Insert Into Upf_Kgl(Member_Id,Mem_Name,Nic,Division)
    Values (Up_Seq.Nextval
    *,:New.Mem_Name*
    *,:New.Nic*
    *,:New.Division);*
    end upf_trig;
    It's worked. but when inserting values to members table, there is an error.
    this is the error
    Error starting at line 21 in command:
    Insert Into Members(Mem_Name,Nic,Full_Name,Age,Sex,Mar_State,Birth_Date,Division,Religon)
    Values(
    *'IA Nawagamuwa'*
    *,'883324356V'*
    *,'Isuru Aravinda Nawagamuwa'*
    *,'22'*
    *,'Male'*
    *,'Single'*
    *,'21-Dec-88'*
    *,'kgl'*
    *,'Buddhist')*
    Error report:
    SQL Error: ORA-00001: unique constraint (SYSTEM.SYS_C004077) violated
    ORA-06512: at "SYSTEM.UPF_TRIG", line 2
    ORA-04088: error during execution of trigger 'SYSTEM.UPF_TRIG'
    *00001. 00000 - "unique constraint (%s.%s) violated"*
    **Cause: An UPDATE or INSERT statement attempted to insert a duplicate key.*
    For Trusted Oracle configured in DBMS MAC mode, you may see
    this message if a duplicate entry exists at a different level.
    **Action: Either remove the unique restriction or do not insert the key.*

  • Issue with INSERT INTO, throws primary key violation error even if the target table is empty

    Hi,
    I am running a simple
    INSERT INTO Table 1 (column 1, column 2, ....., column n)
    SELECT column 1, column 2, ....., column n FROM Table 2
    Table 1 and Table 2 have same definition(schema).
    Table 1 is empty and Table 2 has all the data. Column 1 is primary key and there is NO identity column.
    This statement still throws Primary key violation error. Am clueless about this? 
    How can this happen when the target table is totally empty? 
    Chintu

    Nope thats not true
    Either you're not inserting to the right table or in the background some other trigger code is getting fired which is inserting into some table which causes a PK violation. 
    Please Mark This As Answer if it solved your issue
    Please Vote This As Helpful if it helps to solve your issue
    Visakh
    My Wiki User Page
    My MSDN Page
    My Personal Blog
    My Facebook Page

  • Primary key violation when inserting records with insert_identity and ident_current+x

    My problem is this: I have data in a couple of temporary tables including
    relations (one table referencing records from another table by using
    temporary keys).
    Next, I would like to insert the data from the temp tables to my productive tables which have the same structure but their own identity keys. Hence, I need to translate the 'temporary' keys to regular identity keys in my productive tables.
    This is even more difficult because the system is highly concurrent, i.e. multiple sessions may try to insert
    data that way simultaneously.
    So far we were running the following solution, using a combination of
    identity_insert and ident_current:
    create table doc(id int identity primary key, number varchar(100))
    create table pos (id int identity primary key, docid int references doc(id), qty int)
    create table #doc(idx int, number varchar(100))
    create table #pos (docidx int, qty int)
    insert #doc select 1, 'D1'
    insert #doc select 2, 'D2'
    insert #pos select 1, 10
    insert #pos select 1, 12
    insert #pos select 2, 32
    insert #pos select 2, 9
    declare @docids table(ID int)
    set identity_insert doc on
    insert doc (id,number)
    output inserted.ID into @docids
    select ident_current('doc')+idx,number from #doc
    set identity_insert doc off
    -- Since scope_identity() is not reliable, we get the inserted identity values this way:
    declare @docID int = (select min(ID) from @docids)
    insert pos (docid,qty) select @docID+docidx-1, qty from #pos
    Since the request to ident_current() is located directly in the insert statement, we always have an implicit transaction which should be thread safe to a certain extend.
    We never had a problem with this solution for years until recently when we were running in occasional primary key violations. After some reasearch it turned out, that there were concurrent sessions trying to insert records in this way.
    Does anybody have an explanation for the primary key violations or an alternative solution for the problem?
    Thank you
    David

    >> My problem is this: I have data in a couple of temporary tables including relations (one table referencing records [sic] from another table by using temporary keys [sic]). <<
    NO, your problem is that you have no idea how RDBMS and SQL work. 
    1. Rows are not anything like records; this is a basic concept.
    2. Temp tables are how old magnetic tape file mimic scratch tapes. SQL programmers use CTEs, views, derived tables, etc. 
    3. Keys are a subset of attributes of an entity, fundamental characteristics of them! A key cannot be temporary by definition. 
    >> Next, I would like to insert the data from the temp tables to my production tables which have the same structure but their own IDENTITY keys. Hence, I need to translate the 'temporary' keys to regular IDENTITY keys in my productive tables. <<
    NO, you just get worse. IDENTITY is a 1970's Sybase/UNIX dialect, based on the sequential file structure used on 16-bit mini computers back then. It counts the physical insertion attempts (not even successes!) and has nothing to with a logical data model. This
    is a mag tape drive model of 1960's EDP, and not RDBMS.
    >> This is even more difficult because the system is highly concurrent, i.e. multiple sessions may try to insert data that way simultaneously. <<
    Gee, that is how magnetic tapes work, with queues. This is one of many reasons competent SQL programers do not use IDENTITY. 
    >> So far we were running the following solution, using a combination of IDENTITY_INSERT and IDENT_CURRENT: <<
    This is a kludge, not a solution. 
    There is no such thing as a generic “id” in RDBMS; it has to be “<something in particular>_id” to be valid. You have no idea what the ISO-11179 rules are. Even worse, your generic “id” changes names from table to table! By magic, it starts as a “Doc”,
    then becomes a “Pos” in the next table! Does it wind up as a “doc-id”? Can it become a automobile? A squid? Lady Gaga? 
    This is the first principle of any data model; it is based on the Law of Identity; remember that from Freshman Logic 101? A data element has one and only one name in a model. 
    And finally, you do not know the correct syntax for INSERT INTO, so you use the 1970's Sybase/UNIX dialect! The ANSI/ISO Standard uses a table consrtuctor: 
    INSERT INTO Doc VALUES (1, 'D1'), (2, 'D2'); 
    >> We never had a problem with this solution for years until recently when we were running in occasional PRIMARY KEY violations. After some research it turned out, that there were concurrent sessions trying to insert records [sic] in this way. <<
    “No matter how far you have gone down the wrong road, turn around.” -- Turkish proverb. 
    You have been mimicking a mag tape file system and have not written correct SQL. It has caught up with you in a way you can see. Throw out this garbage and do it right. 
    --CELKO-- Books in Celko Series for Morgan-Kaufmann Publishing: Analytics and OLAP in SQL / Data and Databases: Concepts in Practice Data / Measurements and Standards in SQL SQL for Smarties / SQL Programming Style / SQL Puzzles and Answers / Thinking
    in Sets / Trees and Hierarchies in SQL

  • Insert data into Access with Auto-Increment column

    Is there anyone out there that has come across this problem I am experiencing?
    I have a form I'm trying to submit to an Access DB that has an Auto-Incremented Table Column. I have followed Stefan Cameron's instructions to a "T" on his blog page here:
    http://forms.stefcameron.com/2006/09/18/connecting-a-form-to-a-database/
    but I keep getting the following error"
    GeneralError: Operation failed.
    XFAObject.open:10:XFA:form1[0]:mysubform[0]:myEIFform[0]:overflowLeader[0]:Submit[0]:click
    open operation failed. [Microsoft][ODBC Microsoft Access Driver] Number of query values and destination fields are not the same.
    My OLEDB Connection Record Source is the SQL Query which reads: SELECT FedTaxID, LegalID FROM dbtest; My simple test DB is Access and its only 3 columns; dbID, FedTaxID, LegalID. dbID is the Auto-Incremented Column.
    If I remove the Auto column from my DB table it inserts just fine but I get this error:
    GeneralError: Operation failed.
    XFAObject.open:10:XFA:form1[0]:mysubform[0]:myEIFform[0]:overflowLeader[0]:Submit[0]:click
    ado2xfa operation failed. Item cannot be found in the collection corresponding to the requested name or ordinal.
    I've looked over alot of the blogs and other help forums and there's info on Selects, I don't find much on Inserts.
    Can anyone direct me in the right direction? Thank you.

    First, please pay attention to the forum in which you are posting.  This particular post would be more appropriate to tsql rather than datamining.  Second, what specific problem are you trying to solve.  The code you posted appears to be
    correct.  I will say that your DataTable will likely be a source of future problems if it contains only the 2 columns.

  • Auto Increment Columns Are Not Recognized

    Hi
    I am using postgre 8 and there are some auto incremented columns
    in some tables. The problem is when I create the DataProvider from a table or a view those columns are not recognized by the IDE. I realized this while running the generated SQL. Is this a known issue ? Finally is there a work around this.
    Thanks
    Mehmet Atlihan

    Hi Mehmet,
    Creator requires a JDBC 3 compliant driver and PostgreSQL database driver is not fully compliant. Please take a look at the below thread which discusses about the issue:
    http://swforum.sun.com/jive/thread.jspa?forumID=123&threadID=53064
    Cheers
    Giri

  • What does the setting "auto increment column templates"

    I have noticed that there is now a setting "auto increment column templates" but I cannot find out what this setting does.
    There are no sequences generated nor triggers.
    Version 3.0.
    Thanks, Joep

    There are no sequences generated nor triggersYou need to set column as "auto increment". Then sequence and trigger will be generated for Oracle.
    You can set template for generated sequences and triggers and can override these settings at column level setting explicitly the name of sequence and trigger.
    The sequence and related trigger are not created as objects in physical model, however if there are such objects defined then definition from physical model is used for generated DDL.
    Philip

  • Unique key violation i.e. primary key violation in JSF page

    Hi, I am using Jdeveloper 11.1.1.5.0 and working with adf fusion web application. I have created entity object and view object. In view object I have primary key and I have set it's type to DB sequence. THe problem is though the attribute is DB sequence. IN JSF page it show unique key violation i.e. primary key violation. Please help me

    So, do you have a trigger in the database that updates the value of the primary key? Or do you assign the value in some other way?
    You can check [url http://download.oracle.com/docs/cd/E16162_01/web.1112/e16182/toc.htm]the docs for information about the ways it can be done.

  • How can i create an auto increment column

    Hello Everyone
    We are working on an EAM package which has an auto number facility but that is not meeting our requirement because some 10s and 100s of numbers keep on jumping based on the number of records the child table has.Means every record in my parent table will have some child records in another table which we call it a child table.The number of numbers that will be jumped each time will depend on the number of child records it has. Now we want to create a new column and generate a sequential unique number in my parent table with out linking it to its child table and use this number as a reference number. And we cant do that through our package customization. Can any one guide us if we can meet our requirement through oracle triggers or so.
    Thanks and Regards

    Hi,
    For "Auto-Increment" functionality - you can use a combination of a sequence and a trigger like so:
    create table roles ( role_id INT
                       , role_name VARCHAR2(30) NOT NULL
                       , creation_date DATE DEFAULT SYSDATE NOT NULL
                       , role_description VARCHAR2(255)
                       , CONSTRAINT roles_pk PRIMARY KEY (role_id)
                       , CONSTRAINT roles_uk1 UNIQUE (role_name)
    create sequence role_id_seq
    start with 1
    increment by 1
    nocache;
    CREATE OR REPLACE TRIGGER roles_pk_trig
    BEFORE
    insert on roles
    for each row
    begin
    IF :new.role_id IS NULL THEN
       SELECT role_id_seq.NEXTVAL
       INTO :new.role_id
       FROM dual;
    END IF;
    end;
    /Now any insert which leaves the "ROLE_ID" column NULL will have an auto-incremented value put in for that column. This is similar to an "Autonumber" column in Access.
    Hope this helps...
    Take care.

  • Problem with primary key violation in master-detail screens

    Hi,
    I found a problem/bug in master-detail screens in which the PK of the detail table consist of the PK of the master table and an additional column. E.g. a manually entered sequence 'in parent'.
    I will use the following simple scenario to explain the problem (it's easy to reproduce):
    PROJECT table
    # id (PK)
    * name
    PROJECT REQUIREMENTS table
    # prj_id (PK)
    # sequence_id (PK)
    * description
    Just create the BC EO, VO and AM and set both display properties of the prj_id attribute of the project requirements VO to hidden.
    Create a new screen in the application structure file in which you can select a project (table-form layout) and display the details (table layout) on the same page.
    With this basic setup you can generate the app to enter, update and delete projects and their requirements.
    The problem occurs if you have a project with a least 1 requirements stored in the database and you try to enter a second requirement with an existing sequence_id within the project. This is an use case in which a end-user enters wrong data.
    So assume we have in the database:
    prj_id sequence_id description
    ====== =========== ===========
    1 1 req1
    and the end-user enters (prj_id is entered automatically as it's not displayed):
    1 1 req2 >> user should have enterd sequence_id 2...
    Step 1. If you try to save an error will be displayed:
    JBO-25013: Too many objects match the primary key oracle.jbo.Key[227300 1 ].
    And the sequnece_id is emptied automatically.
    Step 2. So the end-user re-enters the sequence_id but fills in 2 now and saves.
    Another error is displayed: JBO-27014 sequence_id in AppModule is required
    How strange? Everything is filled in already.
    Step 3. If you just hit save again (without changing anything) you got a transaction completed successfully.
    I checked the logfiles and noticed an exception during after executing step 2.
    oracle.jbo.AttrValException: JBO-27014: Attribute SequenceId in AppModule.ProjectRequirementsView2 is required     at oracle.jbo.AttrValException.<init>(AttrValException.java)     at oracle.jbo.server.JboMandatoryAttributesValidator.validate(JboMandatoryAttributesValidator.java)     at oracle.jbo.server.EntityDefImpl.validate(EntityDefImpl.java:2051)     at oracle.jbo.server.EntityImpl.validateEntity(EntityImpl.java:1373)     at mypackage1.ProjectRequirementsImpl.validateEntity(JwTekeningnummerImpl.java:273)     at oracle.jbo.server.EntityImpl.validate(EntityImpl.java:1508)     at oracle.jbo.server.EntityImpl.validateChildren(EntityImpl.java:1232)     at oracle.jbo.server.EntityImpl.validateEntity(EntityImpl.java:1339)     at oracle.jbo.server.EntityImpl.validate(EntityImpl.java:1508)     at oracle.jbo.server.DBTransactionImpl.validate(DBTransactionImpl.java:3965)     at oracle.adf.model.bc4j.DCJboDataControl.validate(DCJboDataControl.java:967)     at oracle.adf.model.binding.DCBindingContainer.validateInputValues(DCBindingContainer.java:1683)     at oracle.jheadstart.view.adfuix.JhsInitModelListener.validateInputValues(JhsInitModelListener.java:193)     at oracle.jheadstart.view.adfuix.JhsInitModelListener._doModelUpdate(JhsInitModelListener.java:166)     at oracle.jheadstart.view.adfuix.JhsInitModelListener.eventStarted(JhsInitModelListener.java:92)     at oracle.cabo.servlet.AbstractPageBroker._fireUIXRequestEvent(Unknown Source)     at oracle.cabo.servlet.AbstractPageBroker.handleRequest(Unknown Source)     at oracle.cabo.servlet.ui.BaseUIPageBroker.handleRequest(Unknown Source)     at oracle.adf.controller.struts.actions.StrutsUixLifecycle$NonRenderingPageBroker.handleRequest(StrutsUixLifecycle.java:325)     at oracle.cabo.servlet.PageBrokerHandler.handleRequest(Unknown Source)     at oracle.adf.controller.struts.actions.StrutsUixLifecycle._runUixController(StrutsUixLifecycle.java:215)     at oracle.adf.controller.struts.actions.StrutsUixLifecycle.processUpdateModel(StrutsUixLifecycle.java:106)     at oracle.jheadstart.controller.strutsadf.action.JhsStrutsUixLifecycle.processUpdateModel(JhsStrutsUixLifecycle.java:140)     at oracle.adf.controller.struts.actions.DataAction.processUpdateModel(DataAction.java:317)     at oracle.jheadstart.controller.strutsadf.action.JhsDataAction.processUpdateModel(JhsDataAction.java:622)     at oracle.adf.controller.struts.actions.DataAction.processUpdateModel(DataAction.java:508)     at oracle.adf.controller.lifecycle.PageLifecycle.handleLifecycle(PageLifecycle.java:112)     at oracle.adf.controller.struts.actions.StrutsUixLifecycle.handleLifecycle(StrutsUixLifecycle.java:70)     at oracle.adf.controller.struts.actions.DataAction.handleLifecycle(DataAction.java:223)     at oracle.jheadstart.controller.strutsadf.action.JhsDataAction.handleLifecycle(JhsDataAction.java:389)     at oracle.adf.controller.struts.actions.DataAction.execute(DataAction.java:155)     at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:484)     at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)     at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1485)     at oracle.jheadstart.controller.strutsadf.JhsActionServlet.process(JhsActionServlet.java:127)     at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:527)     at javax.servlet.http.HttpServlet.service(HttpServlet.java:765)     at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)     at com.evermind.server.http.ResourceFilterChain.doFilter(ResourceFilterChain.java:65)     at oracle.security.jazn.oc4j.JAZNFilter.doFilter(Unknown Source)     at com.evermind.server.http.EvermindFilterChain.doFilter(EvermindFilterChain.java:16)     at oracle.adf.model.servlet.ADFBindingFilter.doFilter(ADFBindingFilter.java:239)     at com.evermind.server.http.EvermindFilterChain.doFilter(EvermindFilterChain.java:20)     at oracle.adf.model.servlet.ADFBindingFilter.doFilter(ADFBindingFilter.java:239)     at com.evermind.server.http.EvermindFilterChain.doFilter(EvermindFilterChain.java:20)     at oracle.jheadstart.controller.CharacterEncodingFilter.doFilter(CharacterEncodingFilter.java)     at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:645)     at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:322)     at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:790)     at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:270)     at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:112)     at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:192)     at java.lang.Thread.run(Thread.java:534)
    This also explains why I got a error message within the application at step 2, but not an expected error message!
    From the logfile I can see something is going wrong in the oracle.jbo.server.EntityImpl.validateEntity method.
    To get more insight what was goning on I overridden the validateEntity method in my VO Impl class:
    protected void validateEntity()
    System.out.println("MARCEL>> sequenceId=" + getSequenceId());
    System.out.println("MARCEL>> description=" + getDescription());
    super.validateEntity();
    In step 1 the validateEntity is not called.
    In step 2 the sequeceId = null (and description = reg2)
    I expected the sequeceId to be 2 now as I entered this. Furthermore if I look at the (JhsActionServlet) request parameters in the log, I can see that the value of the sequenceId was 2. I guess something is going wrong at this point in converting the request parametes to the EO.
    In step 3 the sequeceId = 2 (as expected)
    Note that I'm using the evaluation copy version of JHeadstart 10.1.2.
    If this was patched in any later build, could you please tell which changes I have to make to the JHS sources to solve this problem.
    Regards,
    Marcel

    Marcel,
    I cannot reproduce this in version 10.1.2.2. We did not "fix" this, although changes in the runtime might have fixed this "silently". I suggest you upgrade to 10.1.2.2 and see whether you still get the error.
    Steven Davelaar,
    JHeadstart Team.

  • Auto Increment column in database table

    Hello experts, I am using oracle 11g database at windows 7.I have to create a sequence object and a table with an auto increment ID column.For this I have created a trigger before insert to select next sequence from a sequence object. It works well but Now I have the current sequence is 7 and there are 6 records inserted in table. Now I delete two records.Thus I have only 5 records in table but my current sequence is still 7.So if I put it in id column then a new record will be inserted in table with 7 ID number after 5th ID number.I want this record should be inserted with 6 Id number. For this I tried to not use sequence object.I tried a pl/sql trigger before insert, which will count the all records in table and after increment i put it in ID column to insertion....Is this a professional way..? thank You regards aaditya

    979801 wrote:
    Hello experts, I am using oracle 11g database at windows 7.I have to create a sequence object and a table with an auto increment ID column.For this I have created a trigger before insert to select next sequence from a sequence object. It works well but Now I have the current sequence is 7 and there are 6 records inserted in table. Now I delete two records.Thus I have only 5 records in table but my current sequence is still 7.So if I put it in id column then a new record will be inserted in table with 7 ID number after 5th ID number.I want this record should be inserted with 6 Id number. For this I tried to not use sequence object.I tried a pl/sql trigger before insert, which will count the all records in table and after increment i put it in ID column to insertion....Is this a professional way..? thank You regards aaditya
    Sequences only guarantee unique numbers.  You cannot (and should not) attempt to create gapless sesquences.  That's not how oracle works and will not scale to a multi user application.
    Imagine two people try to insert records at the same time (and have yet to commit), the trigger you create will count the number of records and determine there are 5 records, so assign the next number of 6, for both people who are inserting records.  The first person to commit will get their data saved, and assuming you have a unique constriaint on that id, the second person will raise a duplicate key on insert or suchlike error.
    Gapless sequential numbers are not appropriate to multi-user environments.  Such requirements are often given by managers or business people who do not understand the technology.
    Think of it in terms of a real world office, but with people using a paper system instead of a computer.  The only way you can try to guarantee people get the next number and also re-use numbers that have been deleted is to have a single place where each person in the office goes to, to fetch the next number, and they have to queue up behind each other to get the next one off the list.  But if someone has removed an old record, they've got to wait in the same queue to go and put that number back in the pot for someone else to use.  It just doesn't work, even in a manual system.  Yes, people can guarantee that they're only getting unique numbers that nobody else is using, but they cannot guarantee that they are reusing and filling gaps etc.  It's an unrealistic expectation.

  • Primary Key Violation at the time of Moving from primary range to secondary range.

    Hi Experts,
    I've observed a strange issue in our environment.
    we are using sql server 2008 R2 with SP2.
    whenever a table is moving from primary range to secondary range on it's identity values, application is getting crashed with the message as below. 
    Violation of PRIMARY KEY constraint 'PK6'. Cannot insert duplicate key in object 'dbo.TD_TRANN'. The duplicate key value is (17868679).
    The statement has been terminated.
    OR
    Violation of UNIQUE KEY constraint 'IX_TDS_COST'. Cannot insert duplicate key in object 'dbo.TDS_COST'. The duplicate key value is (17, 19431201).
    identity ranges were auto managed by replication. agents are running continuous.
    please suggest.
    Cheers, Vinod Mallolu

    Well this is pretty simple, so there are two type of subscriptions (Server and client) in merge replication. So while adding article you provide following parameters:
    @pub_identity_range
    @identity_range
    You can check the details of above parameters on following article:http://msdn.microsoft.com/en-us/library/ms174329.aspx
    Snippet
     @pub_identity_range= ]
    pub_identity_range              
    Controls the identity range size allocated to a Subscriber with a server subscription when automatic identity range management is used. This identity range is reserved for a republishing Subscriber to allocate to its own Subscribers.
    pub_identity_range is bigint, with a default of NULL. You must specify this parameter if
    identityrangemanagementoption is auto or if
    auto_identity_range is true.
    [ @identity_range= ]
    identity_range              
    Controls the identity range size allocated both to the Publisher and to the Subscriber when automatic identity range management is used.
    identity_range is bigint, with a default of NULL. You must specify this parameter if
    identityrangemanagementoption is auto or if
    auto_identity_range is true.
    So for example you are adding "Server" type subscription then we consider @pub_identity_range value while assigning the range to that sub. If it is "Client" type subscription in that case we consider @identity_range value.
    You could run following query to check the range assigned to each publisher and subscriber:
    SELECT B.SUBSCRIBER_SERVER,B.DB_NAME,A.* FROM MSMERGE_IDENTITY_RANGE A,SYSMERGESUBSCRIPTIONS B
    WHERE A.SUBID=B.SUBID
    This should answer your other question as well.
    Vikas Rana | Please mark solved if I've answered your question, vote for it as helpful to help other user's find a solution quicker -------------------------------------------------------------------------------- This posting is provided "AS IS"
    with no warranties, and confers no rights. ------------------------------------------------

Maybe you are looking for

  • How do I get my new Mustek scanner to work over Airport Extreme?

    We can't get our new scanner to even show up over our wireless network. When I hook it straight to my iMac (2.8 GHz Intel Core Duo, OS X 10.6.8 [Snow Leopard]), I can use the enclosed software (ImageAcquire), but it does NOT show up either in ImageCa

  • Battery Consumption Up Win 8.1 Update 1 W530

    Fan is running at low audible level constantly with low program load, battery appears to be draining much faster than before 8.1 or 8.1 Update 1.   Running Win 8.1 Update 1 Pro 64 bit, all latest lenovo updates and bios and latest windows updates.  B

  • Can SOA 11g fault policy handle XSD Validation errors from the Mediator?

    I would like all errors in my SOA process to go through the fault-policies.xml. But I don't seem to be able to catch any mediator error caused by an XSD validation failure. A sample of the sort of error I am trying to 'catch' is: Nonrecoverable Syste

  • Apple Imac G5 Wont Run Setup From DVD

    hi guys ive got an apple imac g5 and for some reason it wont run setup from any of the mac dvd's or cd's i have the superdrive spins up and it does nothing even when i press and hold the letter c' key on the keyboard the spec is as follows Imac G5 -

  • How to fix error 45054

    I have uninstalled and re-installed iTunes. I keep getting: We could ot complete your iTunes Store Request. An unknown error occurred (-45054) Try again later. I have been through all the forums but nothing seems to work. Thanks