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

Similar Messages

  • 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.

  • 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

  • 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.

  • 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. ------------------------------------------------

  • 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.

  • Gettin error while setting column as primary key

    Hi I am trying to extract data from XML file
    and create one custom table
    Its working fine when I try following code
    CREATE TABLE xx_PER_ALL_VACANCIES
      AS (SELECT x.* FROM hr_api_transactions t, xmltable('//PerAllVacanciesEORow' passing xmltype(transaction_document) columns location_id NUMBER path 'LocationId', organization_id NUMBER path 'OrganizationId', name VARCHAR2(100) path 'Name', creation_date VARCHAR2(15) path 'CreationDate',PeopleGroupId  NUMBER path 'PeopleGroupId',REQUISITION_ID  NUMBER(15)path 'RequisitionId',COMMENTS LONG() path 'Comments')
      x
    WHERE t.transaction_ref_table = 'PER_ALL_VACANCIES');but when I try to make Name column as primary key then it gives an error
    following is code
    CREATE TABLE xx_PER_ALL_VACANCIES
      AS (SELECT x.* FROM hr_api_transactions t, xmltable('//PerAllVacanciesEORow' passing xmltype(transaction_document) columns location_id NUMBER path 'LocationId', organization_id NUMBER path 'OrganizationId', name NOT NULL VARCHAR2(100) path 'Name', creation_date VARCHAR2(15) path 'CreationDate',PeopleGroupId  NUMBER path 'PeopleGroupId',REQUISITION_ID  NUMBER(15)path 'RequisitionId',COMMENTS LONG() path 'Comments')
      x
    WHERE t.transaction_ref_table = 'PER_ALL_VACANCIES');following is error
    Error at Command Line:2 Column:214
    Error report:
    SQL Error: ORA-00902: invalid datatype
    00902. 00000 - "invalid datatype"
    *Cause:   
    *Action:also it gives error when I takes data type as long() for column Comments
    Error at Command Line:2 Column:392
    Error report:
    SQL Error: ORA-00907: missing right parenthesis
    00907. 00000 - "missing right parenthesis"
    *Cause:   
    *Action:                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

    LONG is not ( and never will be, so don't bother asking) supported by XMLTable. You should use CLOB or BLOB.
    SQL> drop table HR_API_TRANSACTIONS
      2  /
    Table dropped.
    SQL> drop table xx_PER_ALL_VACANCIES
      2  /
    Table dropped.
    SQL> create table HR_API_TRANSACTIONS
      2  (
      3    TRANSACTION_REF_TABLE VARCHAR2(32),
      4    TRANSACTION_DOCUMENT  CLOB
      5  )
      6  /
    Table created.
    SQL> CREATE TABLE xx_PER_ALL_VACANCIES
      2  AS
      3  (
      4    SELECT x.*
      5      FROM hr_api_transactions t,
      6           xmltable
      7           (
      8              '//PerAllVacanciesEORow'
      9              passing xmltype(transaction_document)
    10              columns location_id NUMBER        path 'LocationId',
    11              organization_id     NUMBER        path 'OrganizationId',
    12              name                VARCHAR2(100) path 'Name',
    13              creation_date       VARCHAR2(15)  path 'CreationDate',
    14              PeopleGroupId       NUMBER        path 'PeopleGroupId',
    15              REQUISITION_ID      NUMBER(15)    path 'RequisitionId',
    16              COMMENTS            LONG()        path 'Comments'
    17           )  x
    18     WHERE t.transaction_ref_table = 'PER_ALL_VACANCIES'
    19  )
    20  /
                COMMENTS            LONG()        path 'Comments'
    ERROR at line 16:
    ORA-00907: missing right parenthesis
    SQL> CREATE TABLE xx_PER_ALL_VACANCIES
      2  AS
      3  (
      4    SELECT x.*
      5      FROM hr_api_transactions t,
      6           xmltable
      7           (
      8              '//PerAllVacanciesEORow'
      9              passing xmltype(transaction_document)
    10              columns location_id NUMBER        path 'LocationId',
    11              organization_id     NUMBER        path 'OrganizationId',
    12              name                VARCHAR2(100) path 'Name',
    13              creation_date       VARCHAR2(15)  path 'CreationDate',
    14              PeopleGroupId       NUMBER        path 'PeopleGroupId',
    15              REQUISITION_ID      NUMBER(15)    path 'RequisitionId',
    16              COMMENTS            LONG          path 'Comments'
    17           ) x
    18     WHERE t.transaction_ref_table = 'PER_ALL_VACANCIES'
    19  )
    20  /
    ERROR at line 19:
    ORA-00997: illegal use of LONG datatype
    SQL> CREATE TABLE xx_PER_ALL_VACANCIES
      2  AS
      3  (
      4    SELECT x.*
      5      FROM hr_api_transactions t,
      6           xmltable
      7           (
      8              '//PerAllVacanciesEORow'
      9              passing xmltype(transaction_document)
    10              columns location_id NUMBER        path 'LocationId',
    11              organization_id     NUMBER        path 'OrganizationId',
    12              name                VARCHAR2(100) path 'Name',
    13              creation_date       VARCHAR2(15)  path 'CreationDate',
    14              PeopleGroupId       NUMBER        path 'PeopleGroupId',
    15              REQUISITION_ID      NUMBER(15)    path 'RequisitionId',
    16              COMMENTS            CLOB          path 'Comments'
    17           )  x
    18     WHERE t.transaction_ref_table = 'PER_ALL_VACANCIES'
    19  )
    20  /
    Table created.
    SQL>

  • SSIS Upsert Primary Key Violation error

    Hello,
    I created an SSIS package with look up transform. My source is OLE DB Source and destination is OLEDB destination with Lookup no match output and OLEDB command with Lookup match output.
    I am inserting data in destination database if records donot exist or running a stored proc in OLEDB command if the records already exist.
    Still I am receiving a 
    Violation of PRIMARY KEY constraint 'PK_'. Cannot insert duplicate key in object 'dbo.tablename'. The duplicate key value is (734eb1e6-9987-41b6-a143-0039726df29d)."
    Can some one tell me where I am doing it wrong. Shd I change the lookup transform to a different transform?
    Experts I Need your inputs.
    Thanks a ton

    MERGE command inserts, updates or deletes:
    http://agilebi.com/jwelch/2007/07/05/sql-server-2008-using-merge-from-ssis/#86
    http://technet.microsoft.com/en-us/library/bb522522.aspx
    http://technet.microsoft.com/en-us/library/cc280522.aspx
    Kalman Toth Database & OLAP Architect
    SELECT Video Tutorials 4 Hours
    New Book / Kindle: Exam 70-461 Bootcamp: Querying Microsoft SQL Server 2012

  • Primary key Violation Error

    Hi all...
    I hace created a Master table and a detail table. the detail table can have multiple records corresponding to a code in master table.this is the case which i want but its giving error of violation of primary key in detail table due to bydefault field Code in the table
    Thanks in advance

    Hi
    Good way are creating of UDO using these tables:
    - Master = MASTER_DATA;
    - Details = MASTER_DATA_ROWS.
    If you import data you need to give values to saome SAP attributes.
    Look this link [Thread: How to import data from excel to UserDefined Fields|How to import data from excel to UserDefined Fields;. May be it can help you.
    Regards
    Sierdna S.

  • Problem on getting Primary Key in CMP from a Sequence

    hi friends,
    please examin the code,
    // PersonVO.java
    public class PersonVO impelemnts java.io.Serializable{
    // construtctors
    // getter and setter methods
    private int id;
    private String name;
    // PersonEJB.java
    abstract public class PersonEJB implements EntityBean{
    abstract public void setId(int id);
    abstract public void setName(String name);
    abstract public int getId();
    abstract public String getName();
    public int ejbCreate(PersonVO data){
    setId(data.getId());
    setName(data.getName());
    return null;
    // Other callback methods
    // Application logic methods
    Problem :
    the field id of the table is a sequence. how can i get the next value from the table in the ejb.
    i wand to set that value to the
    setid(...) method
    instead of
    setId(data.getId());
    please help......

    Why are you defining a primery key class (PersonVO) for your EJB ?
    If you have not a compound primary key, you dont need define a primary key class like PersonVO, you just have to define an ejbCreate (int id).
    Fil

  • ODI Selective Reverse throws Primary Key Violation error

    Hi John,
    Hope you are doing good.
    The version of ODI  is 10.1.3.4.5
    I was trying to reverse an MS SQL table using selective reverse and its throwing the below error
    com.microsoft.sqlserver.jdbc.SQLServerException: Violation of PRIMARY KEY constraint 'PK_COL'. Cannot insert duplicate key in object 'dbo.SNP_COL'.
    Also the error says - Technology or Driver does not support Reverse engineering
    I reversed the same table yesterday and it went fine. But today i wanted to reverse an another table from the same database but its giving an error. I tried deleting the Model itself and tried reversing the both tables and now its not reversing the first on either.
    Please suggest.
    Thanks,
    Sravan

    dear
    you have performed more than once the same reverse engineering.
    If the problem is a doubling in snp * repository, you could delete rows via plsql this process and try again
    tell me if this is not working or if

  • How to set  a field primary key in a pre existing table

    Hi,
    Suppose i have a table and no field in it is a primary key like this
    create table t1
    (a number not null,
    b number);
    Later i want to make a as primary key then how to do that?
    I tried with this statement but it gave error
    alter table t1
    modify a primary key;

    I see, you want autogenerated constraint name (I hate that feature). What version are you on? It works on my 10.2.0.4.0:
    SQL> create table t1
      2  (a number not null,
      3  b number);
    Table created.
    SQL> alter table t1
      2  modify a primary key;
    Table altered.
    SQL> SY.

  • Primary key violation

    Hi,
    Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
    PL/SQL Release 11.2.0.1.0 - Production
    CORE 11.2.0.1.0 Production
    TNS for IBM/AIX RISC System/6000: Version 11.2.0.1.0 - Production
    NLSRTL Version 11.2.0.1.0 - Production
    While we Re-Org few tables,we got the below error
    ORA-01452: cannot CREATE UNIQUE INDEX; duplicate keys found.We received 2 times in a table.
    The table has primary key with validate state and not deferrable since creation of the table.
    We unable to find why is it occuring ?
    Is it bug?
    Any suggestions.
    Thanks

    Why is it it seems you never mark most of your questions ANSWERED after people take the time to help you? 15 (11 unresolved)
    >
    How are you telling no error genereated?
    >
    He isn't - you either didn't read or didn't understand his reply.
    He said if you are rebuilding into the same tablespace there won't be any space reduction so why are you doing that. His comment was
    >
    REALIZE that if you did nothing, no errors would be generated.
    >
    That is not the same as what you said 'How are you telling no error genereated?'
    And before you said the command for the index you used was
    >
    4,Alter index MAR_MGR.ADVMTOOLS rebuild;
    >
    And now you say it is
    >
    Alter index MAR_MGR.SYS_C0042499 rebuild tablespace IKEADATA
    >
    How do you expect people to help you if you don't post the commands you are actually using? That just wastes peoples time and confuses the issue.
    You also said this
    >
    we won't recreate the index while doing Re-Org.Usually we perform like below for a table
    >
    What you 'usually' do doesn't matter at all. We need to know what you did this time when you got the error.
    Post the table and all index DDL. Also query the ALL_INDEXES view and post the information for the index; including INDEX_TYPE, UNIQUENESS and TABLESPACE_NAME.

  • New to EJBs  exception in client code

    Hi i am new to EJBs when i execute the client code it is giving the following exceptions
    can any one tell me the steps to execute a simple EJB session bean. what class paths and what config and what xml files are required??
    i followed so many tutorials but the problem is not solved
    thanks
    here is the exception i wrote the JNDI name as "HelloWorld" in the weblogic-ejb-jar.xml (i am using weblogic 8.1 application server)
    Full compiler error(s):
    C:\bea\user_projects\domains\mydomain\.\myserver\.wlnotdelete\extract\myserver_FirstEjb_HelloClient\jsp_servlet\__helloclient.java:139: cannot resolve symbol
    symbol  : class HelloHome
    location: class jsp_servlet.__helloclient
            HelloHome home = (HelloHome) javax.rmi.PortableRemoteObject.narrow(obj,HelloHome.class); //[ /HelloClient.jsp; Line: 17]
            ^
    C:\bea\user_projects\domains\mydomain\.\myserver\.wlnotdelete\extract\myserver_FirstEjb_HelloClient\jsp_servlet\__helloclient.java:139: cannot resolve symbol
    symbol  : class HelloHome
    location: class jsp_servlet.__helloclient
            HelloHome home = (HelloHome) javax.rmi.PortableRemoteObject.narrow(obj,HelloHome.class); //[ /HelloClient.jsp; Line: 17]
                              ^
    C:\bea\user_projects\domains\mydomain\.\myserver\.wlnotdelete\extract\myserver_FirstEjb_HelloClient\jsp_servlet\__helloclient.java:139: cannot resolve symbol
    symbol  : class HelloHome
    location: class jsp_servlet.__helloclient
            HelloHome home = (HelloHome) javax.rmi.PortableRemoteObject.narrow(obj,HelloHome.class); //[ /HelloClient.jsp; Line: 17]
                                                                                   ^
    C:\bea\user_projects\domains\mydomain\.\myserver\.wlnotdelete\extract\myserver_FirstEjb_HelloClient\jsp_servlet\__helloclient.java:140: cannot resolve symbol
    symbol  : class Hello
    location: class jsp_servlet.__helloclient
            Hello hello = home.create(); //[ /HelloClient.jsp; Line: 18]
            ^
    4 errorsand the client jsp file is as follows
      <%@ page import="java.util.*"%>
    <%@ page import="javax.naming.InitialContext"%>
    <%@ page import="javax.naming.Context"%>
    <%@page language="java" contentType="text/html"%>
    <html>
        <head>
            <title>JSP Page</title>
        </head>
        <body>
            <%
                Properties props = System.getProperties();
                   out.println("SREENIVAS  FIRST EJB");
              try {
                   Context ctx = new InitialContext(props);
                Object obj = ctx.lookup("HelloWorld");
                HelloHome home = (HelloHome) javax.rmi.PortableRemoteObject.narrow(obj,HelloHome.class);
                Hello hello = home.create();
                   out.println(hello.hello());
                hello.remove();
                ctx.close();
            } catch (Exception e) {
                e.printStackTrace();
        %></body>
    </html>

    i got the output
    its working
    the change i did is
    i put all the remote,home and local interfaces in a package and added that package to a jar file.
    then i added the jar file to class path.
    import this package into your client class.
    thats it now just deploy your ejbmodule.jar and webapplication.war in the server and test the code
    bye bye

Maybe you are looking for

  • How to use company users on existing ldap server as EP6.0 sp2  Users?

    Hi everybody Our company user data is on a  LDAP server we want to connect our EP6  UME  to this existing LDAP server so that existing company users can access  the Portal with their company id and password. What configuration we should do on the por

  • Itunes will not sync music to Ipod - but shows it has?

    I have a video Ipod, and until today it was working fine Having uploaded CD's to Itunes all day, these were not been added to the ipod, even though they showed in Itunes. The Ipod just showed what was on it before today, none of the new content. I ha

  • Whera can I find RFC adapter file configuration?

    I search for Program ID in RFC Adapter configuration but I don't find the file properties. Where is? thanks, mik

  • Using Message Built-In - Message dialog box appears twice

    Hi all, I'm using the message built-in to display messages in forms. I use the message command twice to make it appear as a dialog box.(Using it once displays it in status bar) Eg. Message('Hello World'); Message('Hello World'); Sometimes, the dialog

  • Error message: internal data error

    Dreamweaver CS5 worked perfectly until this morning, when I keep getting error message: An FTP error encountered, cannot link to host. Encountered an internal data error. What's happening?