Can foreign key refer to unique key?

Hi....

If you join that table x with table y using a
WHERE x.pk_column = y.fk_columnpredicate. Then the rows with "matching" NULL's will not show up in the query result.
But this has nothing to do with an FK referencing a UK.
It has everything to do with how NULL's are treated in the SQL standard.
A predicate like:
NULL = NULLwill evaluate to FALSE (that's just how SQL treats NULL's in this case).

Similar Messages

  • Unique constraint error but key when inserting unique keys!

    Hi,
    I am tring to update an existing database with some older data, I am getting an error which complains about a unique constraint being violated although there is no voilation evident after testing.
    I am puzzled by this and was wondering if someone could give me any extra info on another possible cause.
    I googled but found that this error is caused by duplicating primary keys which I am not doing though I still get this error.
    I run this query then the update and get the output below:
    desc test_sales;
    desc sales_order;
    SELECT order_id FROM sales_order WHERE order_id IN (SELECT order_id FROM test_Sales);
    INSERT INTO sales_order
    (order_id,order_date,customer_id, ship_date,total)
    SELECT 
          order_id,
          order_date,
          cust_id,
          ship_date,
          total
    FROM
          test_sales;
    desc test_sales;
    Name                           Null     Type                                                                                                                                                                                         
    ------------------------------ -------- CUST_ID                                 NUMBER(6)                                                                                                                                                                                    
    OLD_SYSTEM_ID                           VARCHAR2(25)                                                                                                                                                                                 
    DESCRIPTION                             VARCHAR2(35)                                                                                                                                                                                 
    ORDER_DATE                              DATE                                                                                                                                                                                         
    SHIP_DATE                               DATE                                                                                                                                                                                         
    QUANTITY                                NUMBER                                                                                                                                                                                       
    ORDER_ID                       NOT NULL NUMBER(4)                                                                                                                                                                                    
    ITEM_ID                        NOT NULL NUMBER(4)                                                                                                                                                                                    
    SITE_COUNT                              NUMBER(2)                                                                                                                                                                                    
    TOTAL                                   NUMBER(8,2)                                                                                                                                                                                  
    PRODUCT_CODE                            NUMBER(6)                                                                                                                                                                                    
    LIST_PRICE                              NUMBER(8,2)                                                                                                                                                                                  
    12 rows selected
    desc sales_order;
    Name                           Null     Type                                                                                                                                                                                         
    ------------------------------ -------- ORDER_ID                       NOT NULL NUMBER(4)                                                                                                                                                                                    
    ORDER_DATE                              DATE                                                                                                                                                                                         
    CUSTOMER_ID                             NUMBER(6)                                                                                                                                                                                    
    SHIP_DATE                               DATE                                                                                                                                                                                         
    TOTAL                                   NUMBER(8,2)                                                                                                                                                                                  
    5 rows selected
    ORDER_ID              
    0 rows selected
    Error starting at line 7 in command:
    INSERT INTO sales_order
    (order_id,order_date,customer_id, ship_date,total)
    SELECT 
          order_id,
          order_date,
          cust_id,
          ship_date,
          total
    FROM
          test_sales
    Error report:
    SQL Error: ORA-00604: error occurred at recursive SQL level 1
    ORA-06502: PL/SQL: numeric or value error: character string buffer too small
    ORA-06512: at line 8
    ORA-00001: unique constraint (MICHAELKELLY.SYS_C00210356) violatedMessage was edited by:
    Mike1981
    Message was edited by:
    Mike1981

    ORA-00001: unique constraint (MICHAELKELLY.SYS_C00210356) violated
    => check dba_cons_columns to see what the constraint actually exists off

  • Difference between Primary Key and Unique Key with NOT NULL constraint

    As both can be referred to another table.
    Apart from the difference that Primary Key can be only 1 and Unique keys can be multiple,
    is there any difference?
    Like in terms of type of Index?

    PARAG_C wrote:
    As both can be referred to another table.
    Apart from the difference that Primary Key can be only 1 and Unique keys can be multiple,
    is there any difference?
    Like in terms of type of Index?Technically there is almost no difference. Logically the two are often used for slightly different concepts.
    The PK (and with it the index) is often an ID column filled by a seqeunce. This key can then be refenced by foreign key constraints on other tables. it is very useful to have this as a meaningless technical construct. Because then the chance that such a ID needs to be changed is extremly slim.
    The UK (and with it the index) is often one or several columns that represent the logical key for the entity. Foreign key constriants should not point to this. THe chance that this attribute will be changed at some point in time is way higher then for a meaningless number (ID).

  • Primary key,Froign key , Unique key

    I want the answer of following questions.
    1) Primary key create cluster index or simple index?
    2) What is cluster index : I know only( cluster index stored record at physical level in sorted order) if there is another difference then tell me
    3) Can I set relation ship with unique key if it is specified with NOT NULL constraints in a table.
    4) Foreign key creates a index or not?

    Hello
    I want to be at least 6 inches taller, better looking and really good at playing the drums, but that's neither here nor there.
    A simple please never hurts.
    For answers to the first 2 I'd concentrate on the clusters section of the concepts guide as your understanding of what clusters are for and when they should be used appears to be lacking:
    http://download-west.oracle.com/docs/cd/B10501_01/server.920/a96524/c11schem.htm#25479
    and also have a look at this asktom thread:
    http://asktom.oracle.com/pls/ask/f?p=4950:8:6996872588440689863::NO::F4950_P8_DISPLAYID,F4950_P8_CRITERIA:1308402202736
    The last two questions, again you can find the info you need in the concepts guide but
    3) Can I set relation ship with unique key if it is specified with NOT NULL constraints in a table.To set up a foreign key from one table to another, it needs to reference a primary key or a unique key in the target table, the NOT NULL constraint has very little to do with it. A very simple test will show this:
    SQL> create table dt_test(id number);
    Table created.
    SQL> create table dt_test_fk(id number);
    Table created.
    SQL> create table dt_test_fk(id number, pk_id number);
    Table created.
    SQL> alter table dt_test_fk add constraint fk_dt_test_fk FOREIGN KEY(pk_id) references dt_test(id);
    alter table dt_test_fk add constraint fk_dt_test_fk FOREIGN KEY(pk_id) references dt_test(id)
    ERROR at line 1:
    ORA-02270: no matching unique or primary key for this column-list
    SQL> alter table dt_test add constraint uk_dt_test UNIQUE (id);
    Table altered.
    SQL> alter table dt_test_fk add constraint fk_dt_test_fk FOREIGN KEY(pk_id) references dt_test(id);
    Table altered.
    SQL> alter table dt_test modify(id number not null);
    Table altered.
    4) Foreign key creates a index or not? Creating a foreign key on a column does NOT automatically create an index on that column.
    A primary key may create a new index. If an index is already available on the table and it can be used i.e the leading edge of the index holds the columns in the primary key, it will be used rather than creating a new one.
    HTH

  • Is their a difference between primary key and unique key with not null valu

    What is the difference in having a column as primary key and having unique key with not null for the column.
    vinodh

    SBH wrote:
    For quick review, below is the link
    http://www.dba-oracle.com/data_warehouse/clustered_index.htm
    You appear to have stumbled on a site that is a mine of disinformation about Oracle.
    >
    It would be helpful, if you explain it too..thnx !!
    The site is wrong and makes up its own terminology as it goes along.
    If the value for clustering factor approaches the number of blocks in the base table, then the index is said to be clustered. http://www.oracle.com/pls/db112/search?remark=quick_search&word=clustered+index
    There is no create clustered index in Oracle.
    - Clustering factor affects the efficiency of an index.
    - There can be clustered tables that you can create indexes on.
    - An Index Organized table is a similar concept to the Microsoft SQL Server clustered index, but it isn't the same thing at all.

  • Foreign key also refer to unique constraint??

    foreign key also refer to unique constraint.
    (GREAT...)
    1.then table that containt unique constraint act as master table??
    2.IS unique constraint will replace with primary key??
    3.Is unique constraint+not null gives all fuctionality as primary key constraint in ???
    4.if primary key=unique+not null then what is use of primary key????????????
    thanks
    kuljeet pal singh

    When you are establishing a foreign key relationship between two tables, a child record must point to a unique record in the parent table. Typically, the child record points to the primary key of the parent, although any unique field or fields in the parent will do.
    So, a table with a unique constraint can act as a parent table in a foreign key relationship.
    A unique constraint may be replaced with a primary key, but not neccessarily.
    A unique constraint plus a not null constraint is functionally identical to a primary key.
    The principle benefit of a primary key compared to unique plus not null is that it provides additional information to someone looking at the database. The primary key is the unchanging identifier for a particular record. A unique constraint plus a not null constraint only implies uniqueness. It is somewhat common for unique values to change over time, as long as they remain unique, but a primary key should never change.
    TTFN
    John

  • How can I run a check for a record across other records in the same dataset based on unique key constraint?

    Dear community,
    I have a flat data set which I run through a lookup and return. I want to check if at least one of the records matching a unique key constraint had a successful return without merging all the records. Can some one point me in the right direction?
    Thanks!
    Marc

    Hi,
    Sounds like a job for the Lookup Check processor!
    As with all check processors, it adds a flag attribute (with a Y/N value) that denotes if the lookup was successful or not, as well as filtering records based on this at output.
    Lookup Check does the same as Lookup and Return but does not return the record(s) looked up.
    Also note that Lookup and Return does not actually merge records, but it does pull back the return data (which you can then split if you want a record for each).
    Regards,
    Mike

  • The order of a DBDataSource - A unique key (index) can help (but...)

    Hi @all!
    There was often the question, if a DBDataSource could be ORDERed BY sth. Although it would be nice if somebody could disprove that: It's not possible.
    Up to this my experience was that the "items" in a DBDataSource always ordered by the Code-Column. That's what my code in some situations relys on. For example if a B1-form browses by a DBDataSource then the order is not always user friendly based on a column with data the user knows.
    But today I was surprised: "Suddenly" a DBDataSource-browsing form is browsing correctly by a DB-Column which the user is interested in (instead of the code-column) !
    The reason for this is a unique UserKey, which I've created by SDK (UserKeysMD). The form seems to browse by the columns of the key.
    But the common reason seems to be that it's standard SQL-behaviour because doing a simple query (without ORDER BY) in SQL-Management Studio also sorts the results by the unique key.
    But there's one important question left:
    Which key wins and why? There's also the unique index for Code on that table....
    Cheers,
    Roland

    Hello @Petr & @all ,
    last night I came to the conclusion, that I must re-implement the browsing for the 6 existing forms with own code:
    Stepping through a recordset with the data of the Ex-BrowseBy EditTxt with defined ORDER
    Then loading the form with DBDataSource which is restricted by conditions to exactly ONE dataset on each arrow-step. I hope/think it works - I will inform you.
    And here are some things to sort out with David {german - sorry}:
    Hallo David,
    ich habe hier kein UDO verwendet weil...
    ...die Forms viele spez. Funktionen haben die dadurch nicht (oder nur komplizierter) möglich wären.
    ...hauptsächlich aber weil die betroffenen Tabellen auch von einer Schnittstelle zur Betr.-Datenerfassung "gespeist" werden (also nur über DI)
    BrowseBy funktioniert ja auch ohne UDO über ein EditTxt welches an eine column in der tabelle DBDataBinded ist und für das "BrowseBy" aktiviert ist.
    Dies ist für die Tabelle/Formular mit den Hauptobjekten auch ok: es wird automatisch durch alle Hauptobjekte geBrowsed und nach Code wäre zumindest chronologisch alles richtig gewesen (auch nicht schön von dieser Vorgabe abhängig zu sein - hat sich ja jetzt aber erledigt, da die Indexe alles undefiniert würfeln)
    Die Sache wird aber noch etwas komplizierter, da die Hauptobjekte drei mal in Unterobjekte aufgeteilt sind, für die es jeweils auch Formulare gibt. Und diese Formulare sollen nur innerhalb eines Teils der zugehörigen Untertabelle browsen. In der Untertabelle sind aber alle Unterobjekte aller Hauptobjekte enthalten.
    Also habe ich für die Unterobjekt-Form die DBDataSource nach der geBrowsed wird mit Conditions eingeschränkt. Schon hier mußten die Pfeile mit eigener Funktion belegt werden (B1 automatik reicht da nicht)
    Beim browsen in den Unterobjekten ist durch die indexe natürlich nun auch alles durcheinander.
    Das ganze fiel auch nicht sofort ins Auge weil "meistens" Code und eigentliche ObjektSchlüssel durch "chronologische" Eingabe (bzw. import) die gleiche Reihenfolge haben.
    Nur ein Versuch das "mal so eben" zu erklären...
    Viele Grüße,
    Roland

  • Problems Engineering Surrogate Primary Key with Unique Key

    SDDM 3.3.0.747 with 2 problems (at least so far).  I am hoping that the problem is with this SDDM rookie and I have overlooked some setting. PROBLEM 1 I don’t want to start a religious debate about surrogate vs. natural keys but I am having a problem engineering both correctly from the logical model.  I am a rookie when it comes to SDDM but have many years of experience with Designer. By default I like to have both a natural UID  (UK) and a surrogate key based primary UID (PK) which is used for foreign keys.  The problem I am having with engineering is I can successfully engineer the surrogate PK’s, engineer the FK’s using the PK’s but cannot get the unique key to contain the surrogate keys in the child table.  If I check the identifying property in the relations, the PK columns and the UK columns are included in the child PK and the UK contains no columns. The Setup I have defined two reference entities, PROBABILITY and SEVERITY with natural unique keys defined.  I also have a child entity RISK_ASSESMENT with relationships back to the PROBABILITY and SEVERITY entities and both have the “Use surrogate keys:”: check box checked.  The unique key for the RISK_ASSESMENT entity includes the relationships back to PROBILITY and SEVERITY.  None of the entities have a PK or surrogate key defined and they all have the “Create Surrogate Key” check box checked.  In addition the following preferences are set: Data Modeler/Model/Logical   NOT Checked - Use And Set First Unique Key As Primary Key   NOT Checked – Name – Keep as the name of the Originating attribute   Checked – Entity Create Surrogate Key   Checked – Relationship Use Surrogate Key PROBLEM 2 When the foreign key columns are engineered I want the names to have a prefix “FK_” but they don’t.  Templates are set as follows: Data Modeler/Naming Standard/Templates   Foreign Key:  FK_{child}{parent}   Column Foreign Key:  FK_{ref column} Engineer to Relational Model/General Options   Checked - Apply name translation Marcus Bacon

    I have been switching between SD 4 EA1 and SDDM 3.3 trying to get things to work and trying out the template table for adding audit columns (really nice!).
    Concerning Problem1.  No matter what settings I use and whether I use SDDM 3.3 or SDI cannot get the FK columns to be included in the UK even though the relations are included in the UID in the entitty.  When I open the properties of the child table and click on the naming standards button and click ok it complains that the UK is not complete.  I add the FK columns to the UK and all is well including the naming standards.
    Concerning Problem 2.  Sometimes it engineers the names for FK's from the template and sometimes it doesn't.  Didn't see a pattern.  Gave up trying and used Naming Standards button.  I still had to change a few.
    The good new is, that after make changes needed in UK's and Column names of 18 tables, I know have everything deployed to Test except FK Indexes.  I think I have to do those by hand.
    Marcus Bacon

  • Difference between Unique key and Unique index

    Hi All,
    I've got confused in the difference between unique index & unique key in a table.
    While we create a unique index on a table, its created as a unique index.
    On the other hand, if we create a unique key/constraint on the table, Oracle also creates an index entry for that. So I can find the same name object in all_constraints as well as in all_indexes.
    My question here is that if during creation of unique key/constraint, an index is automatically created than why is the need to create unique key and then two objects , while we can create only one object i.e. unique index.
    Thanks
    Deepak

    This is only my understanding and is not according to any documentation, that is as follows.
    The unique key (constraint) needs an unique index for achieving constraint of itself.
    Developers and users can make any constraint (unique-key, primary-key, foreign-key, not-null ...) to enable,disable and be deferable. Unique key is able to be enabled, disabled, deferable.
    On the other hand, the index is used for performance-up originally, unique index itself doesn't have the concept like constraints. The index (including non-unique, unique) can be rebuilded,enabled,disabled etc. But I think that index cannot be set "deferable-builded" automatic.

  • Unique Key Violation error while updating table

    Hi All,
    I am having problem with UNIQUE CONSTRAINT. I am trying to update a table and getting the violation error. Here is the over view. We have a table called ActivityAttendee. ActivityAttendee has the following columns. The problem to debug is this table has
    over 23 million records. How can I catch where my query is going wrong?
    ActivityAttendeeID INT PRIMARY KEY IDENTITY(1,1)
    ,ActivityID INT NOT NULL (Foreign key to parent table Activity)
    ,AtendeeTypeCodeID INT NOT NULL
    ,ObjectID INT NOT NULL
    ,EmailAddress VARCHAR(255) NULL
    UNIQUE KEY is on ActivityID,AtendeeTypeCodeID,ObjectID,EmailAddress
    We have a requirement where we need to update the ObjectID. There is a new mapping where I dump that into a temp table #tempActivityMapping (intObjectID INT NOT NULL, intNewObjectID INT NULL)
    The problem is ActivityAttendee table might already have the new ObjectID and the unique combination.
    For example: ActivityAttendee Table have the following rows
    1,1,1,1,NULL
    2,1,1,2,NULL
    3,1,1,4,'abc'
    AND the temp table has 2,1
    So essentially when I update in this scenario, It should ignore the second row because, if I try updating that there will be a violation of key as the first record has the exact value. When I ran my query on test data it worked fine. But for 23 million records,
    its going wrong some where and I am unable to debug that. Here is my query
    UPDATE AA
    SET AA.ObjectID = TMP.NewObjectID
    FROM dbo.ActivityAttendee AA
    INNER JOIN #tmpActivityMapping TMP ON AA.ObjectID = TMP.ObjectID
    WHERE TMP.NewObjectID IS NOT NULL
    AND NOT EXISTS(SELECT 1
    FROM dbo.ActivityAttendee AA1
    WHERE AA1.ActivityID = AA.ActivityID
    AND AA1.AttendeeTypeCodeID = AA.AttendeeTypeCodeID
    AND AA1.ObjectID = TMP.NewObjectID
    AND ISNULL(AA1.EmailAddress,'') = ISNULL(AA.EmailAddress,'')

    >> I am having problem with UNIQUE CONSTRAINT. I am trying to update a table and getting the violation error. Here is the over view. We have a table called Activity_Attendee. <<
    Your problem is schema design. Singular table names tell us there is only one of them the set. Activities are one kind of entity; Attendees are a totally different kind of entity; Attendees are a totally different kind of entity. Where are those tables? Then
    they can have a relationship which will be a third table with REFERENCES to the other two. 
    Your table is total garbage. Think about how absurd “attendee_type_code_id” is. You have never read a single thing about data modeling. An attribute can be “attendee_type”, “attendee_code” or “attendee_id”but not that horrible mess. I have used something like
    this in one of my busk to demonstrate the wrong way to do RDBMS as a joke, but you did it for real. The postfix is called an attribute property in ISO-11179 standards. 
    You also do not know that RDBMS is not OO. We have keys and not OIDs; but bad programmers use the IDENTITY table property (NOT a column!), By definition, it cannot be a key; let me say that again, by definition. 
    >> ActivityAttendee has the following columns. The problem to debug is this table has over 23 million records [sic: rows are not records]<<
    Where did you get “UNIQUE KEY” as syntax in SQL?? What math are you doing the attendee_id? That is the only reason to make it INTEGER. I will guess that you meant attendee_type and have not taken the time to create an abbreviation encoding it.
    The term “patent/child” table is wrong! That was network databases, not RDBMS. We have referenced and referencing table. Totally different concept! 
    CREATE TABLE Attendees
    (attendee_id CHAR(10) NOT NULL PRIMARY KEY, 
     attendee_type INTEGER NOT NULL  --- bad design. 
        CHECK (attendee_type BETWEEN ?? AND ??), 
     email_address VARCHAR(255), 
    CREATE TABLE Activities
    (activity_id CHAR(10) NOT NULL PRIMARY KEY, 
    Now the relationship table. I have to make a guess about the cardinally be 1:1, 1:m or n:m. 
    CREATE TABLE Attendance_Roster
    (attendee_id CHAR(10) NOT NULL --- UNIQUE??
       REFERENCES Attendees (attendee_id), 
     activity_id Activities CHAR(10) NOT NULL ---UNIQUE?? 
      REFERENCES Activities (activity_id)
     PRIMARY KEY (attendee_id, activity_id), --- wild guess! 
    >> UNIQUE KEY is on activity_id, attendee_type_code_id_value_category, object_id, email_address <<
    Aside from the incorrect “UNIQUE KEY” syntax, think about having things like an email_address in a key. This is what we SQL people call a non-key attribute. 
    >> We have a requirement where we need to update the ObjectID. There is a new mapping where I dump that into a temp table #tempActivityMapping (intObjectID INTEGER NOT NULL, intNewObjectID INTEGER NULL) <<
    Mapping?? We do not have that concept in RDBMS. Also putting meta data prefixes like “int_” is called a “tibble” and we SQL people laugh (or cry) when we see it. 
    Then you have old proprietary Sybase UODATE .. FROM .. syntax. Google it; it is flawed and will fail. 
    Please stop programming until you have a basic understanding of RDBMS versus OO and traditional file systems. Look at my credits; when I tell you, I think I have some authority. 
    --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

  • SQLLDR error 418 - primary key REF

    Has anyone successfully used primary key REF's in SQL*Loader?
    I'm trying to load only the data from a file where it matches a user ID in another table.
    Even running the example from the Oracle documentation gives me the same error.
    Documentation: http://download-west.oracle.com/otndoc/oracle9i/901_doc/server.901/a90192/ch10.htm#1008188
    Error: "SQL*Loader-418: Bad datafile datatype for column CUST"
    I've guessed the structure of the CUSTOMERS and ORDERS tables, as they're not mentioned anywhere that I can see, certainly not in the "Tables Used in the Case Studies" section:
    http://download-west.oracle.com/otndoc/oracle9i/901_doc/server.901/a90192/ch10.htm#1006666
    Any ideas?
    Dan

    Hi
    The problem is that the PK is based on a UDT.
    If you really want to have such a primary key (on my opinion surrogate PK should always be used) you have to specify something like:
    CREATE TABLE Aircraft_tab OF Aircraft_obj (
    PRIMARY KEY(flightID.airline, flightID.num),
    FOREIGN KEY(aircomname) REFERENCES Aircom_tab)
    OBJECT ID PRIMARY KEY;
    Chris

  • Diff b/w primary key and unique key?

    what is the diff b/w primary key and unique key?

    Hi,
    With respect to functionality both are same.
    But in ABAP we only have Primary key for the Database tables declared in the Data Dictionary.
    Unique is generally is the term used with declaring key's for internal tables.
    Both primary and Unique keys can identify one record of a table.
    Regards,
    Sesh

  • How to generate a Unique key based on a some String value

    Hello every one,
    I am sorry , If I post this question in wrong group... I have a requirement to generate a unique key ( what every it may be alpha, numeric or alpha numeric) based on some String..
    For ex : String str = "AbCX" - Gives a unique key based on "AbCX" value..
    Is there any way we can get the unique value using Java ?
    Thanks

    May be not what you are looking for, but here's may idea:
    use a sequence (db sequence) and add it the the string value. This way the value is unique, because the sequence is unique. So you could omit the string theoretically, but your requirement is met.
    It's very easy to get a unique sequence number from the db using java, depending of the technology you use (which you did not say :-( )
    Timo

  • Unique Key Violation While Doing Multiple Updates And Create in EJB

    Hello All,
    I am using oracle 9i and Weblogic 7.0. I have a table that has a unique key constraint on one column , say 'Col1' and i am using a CMP to read,create and update data in this table. The problem description is as follows.
    I have JTable that display the data from the above said table. The user can modify the existing data and insert new data that will be reflected in the DB using the CMP. Let us say the following are displayed
    ROW1
    Col1 : 3
    Col2 : 'ABC'
    Col3 : 1 (Primary key in the table)
    Now the user modifies the above row and inserts a new record. Now the following will be the display
    ROW1 (Modified)
    Col1 : 4
    Col2 : 'ABC'
    Col3 : 1 (Primary key in the table)
    ROW2 (New)
    Col1 : 3
    Col2 : 'DEF'
    Col3 : 2 (Primary key in the table)
    When the above data is saved i do the following in the Code
    a) Session Bean
    For (all the data in the Jtable)
    try
    home.findByPrimaryKey(Col3);
    remote.update(Col1,Col2);
    catch(FinderException fe)
    home.create(Col1,Col2,Col3);
    When the above code is run During the first loop the update runs succesfully (i.e update old value of 3 with 4 ) but during the 2nd loop the create (i.e Insert new value 3) gives me the unique key violated exception. The following is the stack trace
    <Oct 25, 2004 11:36:22 AM IST> <Info> <EJB> <010049> <EJB Exception in method: ejbPostCreate: java.sql.SQLException: ORA-00001: unique constraint (UAT_CYCLE2_1.UK_PYMT_DET_TX) violated
    java.sql.SQLException: ORA-00001: unique constraint (UAT_CYCLE2_1.UK_PYMT_DET_TX) violated
    at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
    at oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java:289)
    at oracle.jdbc.ttc7.Oall7.receive(Oall7.java:579)
    at oracle.jdbc.ttc7.TTC7Protocol.doOall7(TTC7Protocol.java:1892)
    at oracle.jdbc.ttc7.TTC7Protocol.parseExecuteFetch(TTC7Protocol.java:1093)
    at oracle.jdbc.driver.OracleStatement.executeNonQuery(OracleStatement.java:2130)
    at oracle.jdbc.driver.OracleStatement.doExecuteOther(OracleStatement.java:2013)
    at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:2869)
    at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:608)
    at weblogic.jdbc.jts.Statement.executeUpdate(Statement.java:509)
    at de.dl.ucs.contract.entity.TerminalPaymentsCMP_kbdoop__WebLogic_CMP_RDBMS.__WL_create(TerminalPaymentsCMP_kbdoop__WebLogic_CMP_RDBMS.java:1435)
    at de.dl.ucs.contract.entity.TerminalPaymentsCMP_kbdoop__WebLogic_CMP_RDBMS.ejbPostCreate(TerminalPaymentsCMP_kbdoop__WebLogic_CMP_RDBMS.java:1353)
    at java.lang.reflect.Method.invoke(Native Method)
    at weblogic.ejb20.manager.DBManager.create(DBManager.java:1023)
    at weblogic.ejb20.manager.DBManager.localCreate(DBManager.java:904)
    at weblogic.ejb20.internal.EntityEJBLocalHome.create(EntityEJBLocalHome.java:180)
    at de.dl.ucs.contract.entity.TerminalPaymentsCMP_kbdoop_LocalHomeImpl.create(TerminalPaymentsCMP_kbdoop_LocalHomeImpl.java:73)
    at de.dl.ucs.contract.helperclasses.SubsegmentMaintanence.saveTerminalPayments(SubsegmentMaintanence.java:697)
    at de.dl.ucs.contract.controller.SubsegmentSL.saveSubsegmentDetails(SubsegmentSL.java:570)
    at de.dl.ucs.contract.controller.SubsegmentSL.processFinanceSubsegmentSave(SubsegmentSL.java:1601)
    at de.dl.ucs.contract.controller.SubsegmentSL_kgzv4j_EOImpl.processFinanceSubsegmentSave(SubsegmentSL_kgzv4j_EOImpl.java:498)
    at de.dl.ucs.contract.events.FinanceSubsegmentBEH.saveSubsegmentDetails(FinanceSubsegmentBEH.java:749)
    at de.dl.ucs.contract.events.FinanceSubsegmentBEH.processEvent(FinanceSubsegmentBEH.java:232)
    at de.dl.ucs.framework.flowcontroller.ControllerBean.delegateAction(ControllerBean.java:229)
    at de.dl.ucs.framework.flowcontroller.ControllerBean_riqvk4_EOImpl.delegateAction(ControllerBean_riqvk4_EOImpl.java:46)
    at de.dl.ucs.framework.flowcontroller.ControllerBean_riqvk4_EOImpl_WLSkel.invoke(Unknown Source)
    at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:441)
    at weblogic.rmi.cluster.ReplicaAwareServerRef.invoke(ReplicaAwareServerRef.java:114)
    at weblogic.rmi.internal.BasicServerRef$1.run(BasicServerRef.java:382)
    at weblogic.security.service.SecurityServiceManager.runAs(SecurityServiceManager.java:726)
    at weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:377)
    at weblogic.rmi.internal.BasicExecuteRequest.execute(BasicExecuteRequest.java:30)
    at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:234)
    at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:210)
    >
    <Oct 25, 2004 11:36:22 AM IST> <Info> <EJB> <010051> <EJB Exception during invocation from home: [email protected] threw exception: javax.ejb.TransactionRolledbackLocalException: EJB Exception:; nested exception is: java.sql.SQLException: ORA-00001: unique constraint (UAT_CYCLE2_1.UK_PYMT_DET_TX) violated
    Please help me with this, as far as i am concerned since both update and create is in the same transaction the update on the row must be visible to the create and hence there shouild not be any problem.....
    thanks in advance
    Shanki

    Hi,
    Thanks,
    There are 3 columns involved with that table . Out of whihc one is a Primary Key (string) , The other column (Number) has a unique key constraint defined on it and the last column stores a value corresponding to the 2nd column.
    The reason for me to do a create in the Finder exception is as follows.
    I Loop through the Data present in JTable. As given in the example let us assume that there are 2 rows in the JTable. Out of whihc the First row needs an updation and the second row , which is a new row needs to be created. So During the First iteration of the loop, The findermethod does not throw any exception (Because it is a modfied row) and hence the update gets fired successfully. During the second iteration , since it is a new row the findermethod will throw a finder exception and hence create will get fired.
    I understand that this is not a good coding style but then it is not 100% wrong and i need to find out as to why it is not working.
    Hope am clear in explaining my problem
    Thanks
    Shanki

Maybe you are looking for

  • Is there a program I can use to retrieve corrupted .MOV files, from a HD memory card where some files will open, and others wont?

    Hi, I have a Mac OS X version 10.6.8 with a 3.06 GHz Intel Core 2 Duo processor and 4 GB 1067 MHz DDR3 memory. I have recently shot some still and moving footage on my Cannon EOS 500 D (digital camera) using an AMICOE SD C10 8 GB high speed memory ca

  • HELP PLEASEE!

    When i try to update my IPod it says- "Songs on the IPod cannot be updated becuase all of the playlists selected for updating no longer exist" but all my music is still in my Itunes and in my Playlist but not on my IPod?????? Please help.. thanks!

  • Can't pass params in xsql java program

    I tried xsql java program in the xml dev guide. It seems that the program failed to recognize the params. Here is my code:      Hashtable params = new Hashtable (3);      params.put("docid", "801");      params.put("orderby", "citeid");           par

  • Help: Forte on Windows, cant find javax packages

    Forte integration was working fine for me yesterday, and after uninstalling and re-installing (to fix another problem), I now get the following error: Test/TestApp.java [9:1] package javax.microedition.midlet does not exist import javax.microedition.

  • FRM-40735 Error when trying to add an employee as key member for a project

    FRM-40735: ON Insert trigger raised unhandled exception ORA-06502 in PAXPREPR when trying to add an employee as key member for a project Tried generating FND log messages to see if it shows any error messages but it didn't show any specific error.