NULL in primary keys NOT logged to exceptions table

Problem: Inconsistent behavior when enabling constraints using the "EXCEPTIONS INTO" clause. RDBMS Version: 9.2.0.8.0 and 10.2.0.3.0
- NULL values in primary keys are NOT logged to exceptions table
- NOT NULL column constraints ARE logged to exceptions table
-- Demonstration
-- NULL values in primary keys NOT logged to exceptions table
TRUNCATE TABLE exceptions;
DROP TABLE t;
CREATE TABLE t ( x NUMBER );
INSERT INTO t VALUES ( NULL );
ALTER TABLE t
ADD ( CONSTRAINT tpk PRIMARY KEY (x) EXCEPTIONS INTO exceptions );
SELECT * FROM exceptions; -- returns no rows
-- NOT NULL column constraints logged to exceptions table
TRUNCATE TABLE exceptions;
DROP TABLE t;
CREATE TABLE t ( x NUMBER );
INSERT INTO t VALUES ( NULL );
ALTER TABLE t MODIFY ( X NOT NULL EXCEPTIONS INTO EXCEPTIONS );
SELECT * FROM exceptions; -- returns one row
I would have expected all constraint violations to be logged to exceptions. I was not able to find any documentation describing the behavior I describe above.
Can anyone tell me if this is the intended behavior and if so, where it is documented?
I would also appreciate it if others would confirm this behavior on their systems and say if it is what they expect.
Thanks.
- Doug
P.S. Apologies for the repost from an old thread, which someone else found objectionable.

I should have posted the output. Here it is.
SQL>TRUNCATE TABLE exceptions;
Table truncated.
SQL>DROP TABLE t;
Table dropped.
SQL>CREATE TABLE t ( x NUMBER );
Table created.
SQL>INSERT INTO t VALUES ( NULL );
1 row created.
SQL>ALTER TABLE t ADD ( CONSTRAINT tpk PRIMARY KEY (x) EXCEPTIONS INTO exceptions );
ALTER TABLE t ADD ( CONSTRAINT tpk PRIMARY KEY (x) EXCEPTIONS INTO exceptions )
ERROR at line 1:
ORA-01449: column contains NULL values; cannot alter to NOT NULL
SQL>SELECT * FROM exceptions;
no rows selected
SQL>
SQL>TRUNCATE TABLE exceptions;
Table truncated.
SQL>DROP TABLE t;
Table dropped.
SQL>CREATE TABLE t ( x NUMBER );
Table created.
SQL>INSERT INTO t VALUES ( NULL );
1 row created.
SQL>ALTER TABLE t MODIFY ( X NOT NULL EXCEPTIONS INTO EXCEPTIONS );
ALTER TABLE t MODIFY ( X NOT NULL EXCEPTIONS INTO EXCEPTIONS )
ERROR at line 1:
ORA-02296: cannot enable (MYSCHEMA.) - null values found
SQL>SELECT * FROM exceptions;
ROW_ID OWNER TABLE_NAME CONSTRAINT
AAAkk5AAMAAAEByAAA MYSCHEMA T T
1 row selected.
As you can see, I get the expected error message. But I only end up with a record in the exceptions table for the NOT NULL column constraint, not for the null primary key value.

Similar Messages

  • Primary key not available

    Hi!
    When i run my appication client to connect to Oracle9i database i have a next exception:
    javax.ejb.CreateException: java.lang.IllegalStateException: Primary key not available.
    In Oracle i set a primary key field ID.
    Here is my code:
    /* Generated by Together */
    package ejb;
    import javax.ejb.EntityBean;
    import javax.ejb.EntityContext;
    import javax.ejb.EJBException;
    import javax.ejb.CreateException;
    import java.sql.SQLException;
    import java.sql.Connection;
    import javax.naming.InitialContext;
    import javax.naming.NamingException;
    import java.sql.PreparedStatement;
    import javax.ejb.NoSuchEntityException;
    import java.sql.ResultSet;
    import javax.ejb.DuplicateKeyException;
    import javax.ejb.RemoveException;
    import java.util.Collection;
    import java.util.ArrayList;
    import javax.ejb.FinderException;
    import javax.sql.DataSource;
    import java.lang.Integer;
    import java.lang.String;
    import java.rmi.RemoteException;
    import javax.sql.*;
    import java.sql.DriverManager;
    public class TestingBean implements EntityBean {
    private EntityContext ctx;
    public Integer userID;
    public String userLogin;
    public String userPassword;
    public String userPrivilege;
    static private final String users_res_ref = "jdbc/Oracle";
    public void setEntityContext(EntityContext context) throws EJBException {
    System.out.println("EntityContext before = " + ctx);
    ctx = context;
    System.out.println("EntityContext after = " + ctx);
    public void unsetEntityContext() throws EJBException {
    ctx = null;
    public void ejbActivate() throws EJBException {
    public void ejbPassivate() throws EJBException {
    public void ejbRemove() throws EJBException {
    Connection con = null;
    PreparedStatement ps = null;
    try {
    con = getConnection();
    userID = (Integer)ctx.getPrimaryKey();
    ps = con.prepareStatement("DELETE FROM TLogon WHERE Id = ?");
    ps.setInt(1, userID.intValue());
    if (!(ps.executeUpdate() > 0)) {
    throw new RemoveException ("ejbLoad: Can't remove user - " + userID);
    catch (Exception e) {
    throw new EJBException(e);
    finally {
    closeStatement(ps);
    closeConnection(con);
    public void ejbStore() throws EJBException {
    Connection con = null;
    PreparedStatement ps = null;
    try {
    con = getConnection();
    ps = con.prepareStatement("UPDATE TLogon SET Login = ?, Password = ?, Privilege = ? WHERE Id = ?");
    ps.setString(1, userLogin);
    ps.setString(2, userPassword);
    ps.setString(3, userPrivilege);
    ps.setInt(4, userID.intValue());
    ps.executeUpdate();
    catch (Exception e) {
    throw new EJBException(e);
    finally {
    closeStatement(ps);
    closeConnection(con);
    public void ejbLoad() throws EJBException {
    Connection con = null;
    PreparedStatement ps = null;
    userID = (Integer)ctx.getPrimaryKey();
    try {
    con = getConnection();
    ps = con.prepareStatement("SELECT Id, Login, Password, Privilege FROM TLogon WHERE Id = ?");
    ps.setInt(1, userID.intValue());
    ps.executeQuery();
    ResultSet rs = ps.getResultSet();
    rs.next();
    userLogin = rs.getString("Login");
    userPassword = rs.getString("Password");
    userPrivilege = rs.getString("Privilege");
    catch (Exception e) {
    throw new EJBException("ejbLoad: Can't load user - " + userID);
    finally{
    closeStatement(ps);
    closeConnection(con);
    public Integer ejbCreate(Integer aUserID, String aUserLogin, String aUserPassword, String aUserPrivilege) throws CreateException, EJBException, SQLException {
    System.out.println("Inititialization parameters...");
    this.userID = aUserID;
    this.userLogin = aUserLogin;
    this.userPassword = aUserPassword;
    this.userPrivilege = aUserPrivilege;
    System.out.println("Setting connection to null...");
    Connection con = null;
    PreparedStatement ps = null;
    try {           
    System.out.println("Getting connection...");
    con = getConnection();
    System.out.println("EntityContext before getting primary key... = " + ctx);
    System.out.println("Getting primary key...");
    userID = (Integer)ctx.getPrimaryKey();
    System.out.println("Primary key is done...");
    ps = con.prepareStatement("INSERT INTO TLogon (Id, Login, Password, Privilege) VALUES (?,?,?)");
    System.out.println("Inserting data...");
    ps.setInt(1, userID.intValue());
    ps.setString(2, userLogin);
    ps.setString(3, userPassword);
    ps.setString(4, userPrivilege);
    ps.executeUpdate();
    return aUserID;
    catch (Exception e) {
    throw new CreateException(e.toString());
    finally{
    closeStatement(ps);
    closeConnection(con);
    public Integer ejbFindByPrimaryKey(java.lang.Integer pk) throws FinderException, EJBException {
    Connection con = null;
    PreparedStatement ps = null;
    try {
    con = getConnection();
    ps = con.prepareStatement("SELECT Id, Login, Password, Privilege FROM TLogon WHERE Id = ?");
    ps.setInt(1, pk.intValue());
    ps.executeQuery();
    ResultSet rs = ps.getResultSet();
    rs.next();
    return pk;
    catch(Exception e) {
    throw new FinderException (e.toString());
    finally {
    closeStatement(ps);
    closeConnection(con);
    public void ejbPostCreate(Integer aUserID, String aUserLogin, String aUserPassword, String aUserPrivilege) throws CreateException, EJBException, SQLException {
              /* Write your code here */
    public Collection ejbFindAllUsers() throws EJBException, FinderException {
    Connection con = null;
    PreparedStatement ps = null;
    try {
    con = getConnection();
    ps = con.prepareStatement("SELECT Id FROM TLogon");
    ps.executeQuery();
    ResultSet rs = ps.getResultSet();
    ArrayList v = new ArrayList();
    Integer pk;
    while(rs.next()) {
    pk = new Integer(rs.getInt(1));
    v.add(pk);
    return v;
    catch(Exception e) {
    throw new FinderException(e.toString());
    finally {
    closeStatement(ps);
    closeConnection(con);
    public Integer getUserID() throws RemoteException, EJBException {return userID;}
    public void setUserID(Integer param) throws RemoteException, EJBException {this.userID = param;}
    public String getUserLogin() throws RemoteException, EJBException {return userLogin;}
    public void setUserLogin(String param) throws RemoteException, EJBException {this.userLogin = param;}
    public String getUserPassword() throws RemoteException, EJBException {return userPassword;}
    public void setUserPassword(String param) throws RemoteException, EJBException {this.userPassword = param;}
    public String getUserPrivilege() throws RemoteException, EJBException {return userPrivilege;}
    public void setUserPrivilege(String param) throws RemoteException, EJBException {this.userPrivilege = param;}
    private Connection getConnection() throws SQLException {
    InitialContext initCtx = null;
    try {
    initCtx = new InitialContext();
    DataSource ds = (javax.sql.DataSource)initCtx.lookup("java:comp/env/" + users_res_ref);
    return ds.getConnection();
    catch (Exception e) {
    throw new EJBException(e);
    private void closeStatement(PreparedStatement ps) {
    try {
    if (ps != null) {ps.close();}
    catch (Exception e) {
    throw new EJBException(e);
    private void closeConnection(Connection con) {
    try {
    if(con != null) {con.close();}
    catch(Exception e) {
    throw new EJBException(e);
    What i do wrong?
    Please help!!!!

    Very BIG thank you!!!!
    That's right, but i must delete this method only in ejbCreate?
    And i have a next exception: java.sql.SQLException: ORA-00947: not enough values. Why?
    Here is my code db:
    CREATE TABLE "SYSTEM"."TLOGON" ("ID" NUMBER(20) NOT NULL, "LOGIN"
    VARCHAR2(20 byte) NOT NULL, "PASSWORD" VARCHAR2(20 byte) NOT
    NULL, "PRIVILEGE" VARCHAR2(20 byte) NOT NULL,
    CONSTRAINT "ID" PRIMARY KEY("ID")
    USING INDEX
    TABLESPACE "SYSTEM"
    STORAGE ( INITIAL 12K NEXT 12K MINEXTENTS 1 MAXEXTENTS
    2147483645 PCTINCREASE 50 FREELISTS 1 FREELIST GROUPS 1)
    PCTFREE 10 INITRANS 2 MAXTRANS 255)
    TABLESPACE "SYSTEM" PCTFREE 10 PCTUSED 40 INITRANS 1
    MAXTRANS 255
    STORAGE ( INITIAL 12K NEXT 12K MINEXTENTS 1 MAXEXTENTS 249
    PCTINCREASE 50 FREELISTS 1 FREELIST GROUPS 1)
    LOGGING
    And my client:
    package ejb.client;
    import javax.naming.Context;
    import javax.rmi.PortableRemoteObject;
    import ejb.TestingHome;
    import ejb.Testing;
    import java.util.Collection;
    import java.rmi.RemoteException;
    import javax.ejb.FinderException;
    import javax.naming.InitialContext;
    public class TestingClient {
    public static void main(String []args) {
    try {
    System.out.println("Step #1");
    Context initial = new InitialContext();
    System.out.println("Step #2");
    Object objref = initial.lookup("java:comp/env/ejb/SimpleTesting");
    System.out.println("Step #3");
    ejb.TestingHome home = (ejb.TestingHome)PortableRemoteObject.narrow(objref, ejb.TestingHome.class);
    System.out.println("Step #4");
    ejb.Testing aTesting;
    for(int i = 0; i < 3; i++) {
    String login = users[0];
    String password = users[i][1];
    String privilege = users[i][2];
    System.out.println("Adding user..." + login + "\n" + password + "\n" + privilege);
    home.create(new Integer(i+1), login, password, privilege);
    Integer i = new Integer(2);
    home.create(i, "Zatoka", "password", "admin");
    catch(Exception e) {
    e.printStackTrace();
    //private static String JNDI = "ejb.TestingHome";
    private final static String[][] users = {{"Zatoka","*****","admin"}, {"Ivanov","234fds","user"},{"Petrov","dcd2","user"}};
    BIG thanks!!!

  • [Incoming Payments for WTax] Primary Key not exist in DB

    While performing the TDS upgrade, I am getting an error message as "[Incoming Payments for WTax] Primary Key not exist in DB".
    I have checked that the sheet conforms to the instructions provided in the Upgrade guide but am not able to resolve this.
    Any ideas?
    Regards,
    Gyanesh

    Hi,
    It seems to be some field in the TDS upload Excel sheet which has primary key field not having the correct value.
    Double check the same where Primary Key if linked with some value in other sheet, enter the same.
    Kind Regards,
    Jitin
    SAP Business One Forum Team

  • How to transfer database table contain null values, primary key, and foreign key to the another database in same server. using INSERT method.

    how to transfer database table contain null values, primary key, and foreign key to the another database in same server. using INSERT method.  thanks

    INSERT targetdb.dbo.tbl (col1, col2, col3, ...)
       SELECT col1, col2, col3, ...
       FROM   sourcedb.dbo.tbl
    Or what is your question really about? Since you talke about foreign keys etc, I suspect that you want to transfer the entire table definition, but you cannot do that with an INSERT statement.
    Erland Sommarskog, SQL Server MVP, [email protected]

  • Adding 2 new fields as Primary Key field in a Z Table which is existing PRD

    Hi Friends,
    I have to add two new fields as primary key fields in a Z TABLE, which is existing in Quality and Production Systems with Data.
    If I incorporate these two new fields (Primary Key fields) in development and if the TR is moved to Quality and Production sytems, is there any possibility of loss in data will happen at Quality and Prd systems?
    At present, Table is having 20 fields with 2 primary key fields and i have to add 2 more primary key fields.
    I have checked in SCN and not find relevant threads.
    Please help me out.
    Regards,
    Suresh.

    NO . It wont be a problem .
    For ex :
    If you have VBELN  , POSNR are key fields now , you have an unique reord with that combination .
    If you add one other field in it  fo ex  VKBUR  then records will be like this
    VBELN     POSNR     VKBUR   MATERIAL   QTY
    10020      10                            abcxyz      1
    10020      10            1234        abcxyz     1
    So your previous records before adding new primary keys , will have new fields balnk , and the new records will have data filled up in all primary key fields .
    However , if you try to update the existing records that will be in existing PRIMARYKEY combination only .
    for example if you try update record 1 above with VKBUR value 85858 , it creates a new record , it wont be updated in existing record.
    Hope this helps , Pls let me know if u have any more doubts.

  • How add primary key constraint to already existing table with data

    I want apply primary key constraint to already existing table with data
    is there any command or way to do

    Alternatively, assuming you want to ensure uniqueness in your primary key column you can do this:
    alter table <table name> add constraint <cons name> primary key (col1,col2) exceptions into <exception_table>
    If the altter table statement fails this will populate the EXCEPTIONS table with the rows that contain duplicate values for (col1,col2).
    You will need to run (or get a DBA to run) a script called UTLEXCPT.SQL (which will be in the $ORACLE_HOME/rdbms/admin directory) if you don't already have an EXCEPTIONS table.
    Cheers, APC

  • How to know primary key column name form a table name in sql query

    Suppose I only know the table name. How to get its primary key column name from the table name?
    Thanks

    Views don't have primary keys though their underlying tables might. You'd need to pick apart the view to determine where it's columns are coming from.
    You can select the text of the view in question from user_views.

  • Knowing the primary key columns of the given table

    Hi,
    How can I get the primary key columns of the given table?
    Regards,
    Sachin R.K.

    You can find the constraint_name from all_constraints/user_constraints for constraint_type = 'P' (which is the primary key constraint).
    And then see which columns are in for the constriant_name
    in all_cons_columns/user_cons_columns view.
    Below is the example
    select acc.column_name from
    all_cons_columns acc, all_constraints ac
    where acc.constraint_name = ac.constraint_name
    and acc.table_name = 'DEPT' AND acc.owner = 'SCOTT'
    and ac.constraint_type = 'P'
    Hope this helps
    Srinivasa Medam

  • Primary key constraint for index-organized tables or sorted hash cluster

    We had a few tables dropped without using cascade constraints. Now when we try to recreate the table we get an error message stating that "name already used by an existing constraint". We cannot delete the constraint because it gives us an error "ORA-25188: cannot drop/disable/defer the primary key constraint for index-organized tables or sorted hash cluster" Is there some sort of way around this? What can be done to correct this problem?

    What version of Oracle are you on?
    And have you searched for the constraint to see what it's currently attached to?
    select * from all_constraints where constraint_name = :NAME;

  • EJB Primary Key not found in lock manager - Container BUG?

    I have an EJB entity bean whose primary key class implementation is pretty simple, consisting of two strings. For the MOST part, it seems to work properly, but every so often I see the following message in my application server log.
    ####<Sep 17, 2008 10:03:27 AM EDT> <Warning> <JTA> <armantac22> <AdminServer> <[ACTIVE] ExecuteThread: '1' for queue: 'weblogic.kernel.Default (self-tuning)'> <<anonymous>> <> <> <1221660207187> <BEA-110401> <Ignoring error in afterCompletion. Object=weblogic.ejb.container.internal.TxManager$TxListener@1906466, Exception=javax.ejb.EJBException: [EJB:010108]The EJB Lock Manager has received an unlock request from EJB:PortfolioMetaData with primary key:[ObjectPK: type: PortMetaData name: PortMetaData]. However, this primary key could not be found in the Lock Manager. This indicates either an EJB container bug, or the equals and hashCode methods for the primary key class:com.armanta.ejb.ObjectPK are implemented incorrectly. Please check the equals and hashCode implementations.
    javax.ejb.EJBException: [EJB:010108]The EJB Lock Manager has received an unlock request from EJB:PortfolioMetaData with primary key:[ObjectPK: type: PortMetaData name: PortMetaData]. However, this primary key could not be found in the Lock Manager. This indicates either an EJB container bug, or the equals and hashCode methods for the primary key class:com.armanta.ejb.ObjectPK are implemented incorrectly. Please check the equals and hashCode implementations.
         at weblogic.ejb.container.locks.ExclusiveLockManager$LockBucket.unlock(ExclusiveLockManager.java:409)
         at weblogic.ejb.container.locks.ExclusiveLockManager.unlock(ExclusiveLockManager.java:170)
         at weblogic.ejb.container.manager.ExclusiveEntityManager.afterCompletion(ExclusiveEntityManager.java:723)
         at weblogic.ejb.container.manager.ExclusiveEntityManager.afterCompletion(ExclusiveEntityManager.java:667)
         at weblogic.ejb.container.internal.TxManager$TxListener.afterCompletion(TxManager.java:984)
         at weblogic.transaction.internal.ServerSCInfo.callAfterCompletions(ServerSCInfo.java:862)
         at weblogic.transaction.internal.ServerTransactionImpl.callAfterCompletions(ServerTransactionImpl.java:2913)
         at weblogic.transaction.internal.ServerTransactionImpl.afterCommittedStateHousekeeping(ServerTransactionImpl.java:2806)
         at weblogic.transaction.internal.ServerTransactionImpl.setCommitted(ServerTransactionImpl.java:2851)
         at weblogic.transaction.internal.ServerTransactionImpl.globalRetryCommit(ServerTransactionImpl.java:2650)
         at weblogic.transaction.internal.ServerTransactionImpl.globalCommit(ServerTransactionImpl.java:2570)
         at weblogic.transaction.internal.ServerTransactionImpl.internalCommit(ServerTransactionImpl.java:277)
         at weblogic.transaction.internal.ServerTransactionImpl.commit(ServerTransactionImpl.java:226)
         at weblogic.ejb.container.internal.BaseEJBHome.postHomeInvoke(BaseEJBHome.java:389)
         at weblogic.ejb.container.internal.EntityEJBHome.findByPrimaryKey(EntityEJBHome.java:408)
         at com.armanta.ejb.portfolio.PortfolioMetaData_a4zvzk_HomeImpl.findByPrimaryKey(PortfolioMetaData_a4zvzk_HomeImpl.java:64)
         at com.armanta.ejb.portfolio.PortfolioMasterBean.getPortfolioMetaData(PortfolioMasterBean.java:313)
         at com.armanta.ejb.portfolio.PortfolioMaster_fmk9e8_EOImpl.getPortfolioMetaData(PortfolioMaster_fmk9e8_EOImpl.java:64)
         at com.armanta.ejb.portfolio.PortfolioMaster_fmk9e8_EOImpl_WLSkel.invoke(Unknown Source)
         at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:517)
         at weblogic.rmi.cluster.ClusterableServerRef.invoke(ClusterableServerRef.java:224)
         at weblogic.rmi.internal.BasicServerRef$1.run(BasicServerRef.java:407)
         at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:363)
         at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:147)
         at weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:403)
         at weblogic.rmi.internal.BasicServerRef.access$300(BasicServerRef.java:56)
         at weblogic.rmi.internal.BasicServerRef$BasicExecuteRequest.run(BasicServerRef.java:934)
         at weblogic.work.ExecuteThread.execute(ExecuteThread.java:207)
         at weblogic.work.ExecuteThread.run(ExecuteThread.java:179)
    I checked the equals and hashCode implementations and nothing pops out at me. Once this happens, the EJB seems to get messed up in the database and I lose information!
    Here is the class implementation along with its superclass. I don't see anything blatant. Sorry for the lack of indentation, my original post was indented.
    Thanks
    Eric
    public class ObjectPK extends ArmantaPK {
         private String type;
         private String name;
         private ObjectPK() {
              super();
         public ObjectPK(String type, String name) {
              super();
              this.type = type;
              this.name = name;
         public String getName() {
              return name;
         public String getType() {
              return type;
         public String toString() {
              StringBuffer buffer = new StringBuffer();
              buffer.append("[ObjectPK:");
              buffer.append(" type: ");
              buffer.append(type);
              buffer.append(" name: ");
              buffer.append(name);
              buffer.append("]");
              return buffer.toString();
         * Returns <code>true</code> if this <code>ObjectPK</code> is the same as the o argument.
         * @return <code>true</code> if this <code>ObjectPK</code> is the same as the o argument.
         public boolean equals(Object o) {
              if (this == o) {
                   return true;
              if (!super.equals(o)) {
                   return false;
              if (o == null) {
                   return false;
              if (o.getClass() != getClass()) {
                   return false;
              ObjectPK castedObj = (ObjectPK) o;
              return ((this.type == null ? castedObj.type == null : this.type
                   .equals(castedObj.type)) && (this.name == null
                   ? castedObj.name == null
                   : this.name.equals(castedObj.name)));
         * Override hashCode.
         * @return the Objects hashcode.
         public int hashCode() {
              int hashCode = super.hashCode();
              hashCode = 31 * hashCode + (type == null ? 0 : type.hashCode());
              hashCode = 31 * hashCode + (name == null ? 0 : name.hashCode());
              return hashCode;
         public Object clone() {
              ObjectPK inst = new ObjectPK();
              inst.type = this.type == null ? null : new String(this.type);
              inst.name = this.name == null ? null : new String(this.name);
              return inst;
    public abstract class ArmantaPK implements Serializable, Cloneable, Comparable {
         // Enforce compatability with future versions
         private static final long serialVersionUID = 1980721424128862564L;
         // Cache the hash code
         private transient int hash = 0;
         * Clones a primary key. Note that this is not a deep copy.
         * @return the cloned primary key
         public Object clone() throws CloneNotSupportedException {
              ArmantaPK newKey = (ArmantaPK) super.clone();
              newKey.hash = 0;
              return newKey;
         * Compare the specified object with this key for equality.
         * Implementations should return <tt>true</tt>
         * if and only if the specified object is also a key
         * of the same class and all corresponding attributes in the keys are
         * <i>equal</i>.
         * @param other the object to be compared for equality with this key.
         * @return <tt>true</tt> if the specified object is equal to this key.
         public boolean equals(Object other) {
              return other instanceof ArmantaPK;
         * This implementation only returns an empty String.
         * @return String
         public String toString() {
              return "";
         * Return the hash code value for this key. Implemented to call the
         * key's <code>computeHash</code> method and cache the result for
         * faster operation. Classes extending <code>ArmantaPK</code> should
         * only implement <code>computeHash</code>.
         * @return int
         public int hashCode() {
              if (hash == 0) {
                   hash = computeHash();
              return hash;
         * @y.exclude
         * Compute a hash code for this key. This is the method that should
         * be overridden by sub-classes.
         * @return int
         protected int computeHash() {
              return 0;
         * @y.exclude
         * After called, will force the hash code to get recomputed.
         public void rehash() {
              hash = 0;
         * Compares this <tt>ArmantaPK</tt> to another object by comparing
         * their string representations.
         * @return an integer based upon comparing the <tt>ArmantaPK</tt>s string
         * representations
         public int compareTo(Object o) {
    return toString().compareTo(o.toString());
    }

    We are experiencing a similar error after upgrading 9.2 to 9.2 MP3. We do not want to upgrade to 10g at this time. Is there a patch we can download with the fix?

  • Primary key  not getting altered

    Hi,
    I dropeed the Primary key and recreated it with an additional column, but I am getting "name already used by an existing object error". Please advise.
    ALTER TABLE acct DROP PRIMARY KEY CASCADE;
    ALTER TABLE acct ADD (
    CONSTRAINT acct_PK
    PRIMARY KEY
    (ACCT_ID,AS_OF_DT)
    USING INDEX);
    What changes do I need to do to this sql?
    Regards

    Check this out -- Dropping primary key, doesn't  drop associated index in 10G
    This resembles yours.
    From same post,
    1]
    Richard Foote (an Oracle ACE Employee & an 'Index' guru) says -
    >
    Remember, Oracle will only drop an index automatically if the Index is unique, the default behaviour is to keep a non-unique index that polices at PK constraint.
    >
    2]
    Dion Cho (Oracle ACE Member) also demonstrated -
    >
    Even with unique index, Oracle seems to deny to drop corresponding index when Index was explicitly created.
    >
    Please go through the post and workouts carefully.
    Edited by: ranit B on Dec 22, 2012 1:58 PM

  • Create a materized view without primary key constraint on the base table?

    Hi
    I tried to create a materized view but I got this error:
    SQL> CREATE MATERIALIZED VIEW TABLE1_MV REFRESH FAST
    START WITH
    to_date('04-25-2009 03:00:13','MM-dd-yyyy hh24:mi:ss')
    NEXT
    sysdate + 1
    AS
    select * from TABLE1@remote_db
    SQL> /
    CREATE MATERIALIZED VIEW TABLE1_MV REFRESH FAST
    ERROR at line 1:
    ORA-12014: table 'TABLE1' does not contain a primary key constraint.
    TABLE1 in remote_db doesn't have a primary key constraint. Is there anyway that I can create a materized view on a base table which doesn't have a primary key constraint?
    Thanks
    Liz

    Hi,
    Thanks for your helpful info. I created a materialized view in the source db with rowid:
    SQL> CREATE MATERIALIZED VIEW log on TABLE1 with rowid;
    Materialized view log created.
    Then I created a MV on the target DB:
    CREATE MATERIALIZED VIEW my_schema.TABLE1_MV
    REFRESH FAST
    with rowid
    START WITH
    to_date('04-25-2009 03:00:13','MM-dd-yyyy hh24:mi:ss')
    NEXT
    sysdate + 1
    AS
    select * from TABLE1@remote_db
    SQL> /
    CREATE MATERIALIZED VIEW my_schema.TABLE1_MV
    ERROR at line 1:
    ORA-12018: following error encountered during code generation for
    "my_schema"."TABLE1_MV"
    ORA-00942: table or view does not exist
    TABLE1 exists in remote_db:
    SQL> select count(*) from TABLE1@remote_db;
    COUNT(*)
    9034459
    Any clue what is wrong?
    Thanks
    Liz

  • Dynamic SQL Joining between tables and Primary keys being configured within master tables

    Team , Thanks for your help in advance !
    I'm looking out to code a dynamic SQL which should refer Master tables for table names and Primary keys and then Join for insertion into target tables .
    EG:
    INSERT INTO HUB.dbo.lp_order
    SELECT *
    FROM del.dbo.lp_order t1
    where not exists ( select *
    from hub.dbo.lp_order tw
    where t1.order_id = t2.order_id )
    SET @rows = @@ROWCOUNT
    PRINT 'Table: lp_order; Inserted Records: '+ Cast(@rows AS VARCHAR)
    -- Please note Databse names are going to remain the same but table names and join conditions on keys
    -- should vary for each table(s) being configured in master tables
    Sample of Master configuration tables with table info and PK Info :
    Table Info         
    Table_info_ID    Table_Name    
    1        lp_order    
    7        lp__transition_record    
    Table_PK_Info        
    Table_PK_Info_ID    Table_info_ID    PK_Column_Name
    2                1    order_id
    8                7    transition_record_id
    There can be more than one join condition for each table
    Thanks you !
    Rajkumar Yelugu

    Hi Rajkumar,
    It is glad to hear that you figured the question out by yourself.
    There's a flaw with your while loop in your sample code, just in case you hadn't noticed that, please see below.
    --In this case, it goes to infinite loop
    DECLARE @T TABLE(ID INT)
    INSERT INTO @T VALUES(1),(3),(2)
    DECLARE @ID INT
    SELECT @ID = MIN(ID) FROM @T
    WHILE @ID IS NOT NULL
    PRINT @ID
    SELECT @ID =ID FROM @T WHERE ID > @ID
    So a cursor would be the appropriate option in your case, please reference below.
    DECLARE @Table_Info TABLE
    Table_info_ID INT,
    Table_Name VARCHAR(99)
    INSERT INTO @Table_Info VALUES(1,'lp_order'),(7,'lp__transition_record');
    DECLARE @Table_PK_Info TABLE
    Table_PK_Info_ID INT,
    Table_info_ID INT,
    PK_Column_Name VARCHAR(99)
    INSERT INTO @Table_PK_Info VALUES(2,1,'order_id'),(8,7,'transition_record_id'),(3,1,'order_id2')
    DECLARE @SQL NVarchar(MAX),
    @ID INT,
    @Table_Name VARCHAR(20),
    @whereCondition VARCHAR(99)
    DECLARE cur_Tabel_Info CURSOR
    FOR SELECT Table_info_ID,Table_Name FROM @Table_Info
    OPEN cur_Tabel_Info
    FETCH NEXT FROM cur_Tabel_Info
    INTO @ID, @Table_Name
    WHILE @@FETCH_STATUS = 0
    BEGIN
    SELECT @whereCondition =ISNULL(@whereCondition+' AND ','') +'t1.'+PK_Column_Name+'='+'t2.'+PK_Column_Name FROM @Table_PK_Info WHERE Table_info_ID=@ID
    SET @SQL = 'INSERT INTO hub.dbo.'+@Table_Name+'
    SELECT * FROM del.dbo.'+@Table_Name+' AS T1
    WHERE NOT EXISTS (
    SELECT *
    FROM hub.dbo.'+@Table_Name+' AS T2
    WHERE '+@whereCondition+')'
    SELECT @SQL
    --EXEC(@SQL)
    SET @whereCondition = NULL
    FETCH NEXT FROM cur_Tabel_Info
    INTO @ID, @Table_Name
    END
    Supposing you had noticed and fixed the flaw, your answer sharing is always welcome.
    If you have any question, feel free to let me know.
    Eric Zhang
    TechNet Community Support

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

  • Error when i set primary key to a field in table

    I created a table. with one primary key field
    on saving it following error happened 
    at Microsoft.SqlServer.Management.DataTools.Interop.IDTDocTool.Save(Object dsRef, String path, Boolean okToOverwrite)
    at Microsoft.SqlServer.Management.UI.VSIntegration.Editors.VsDataDesignerNode.Save(VSSAVEFLAGS dwSave, String strSilentSaveAsName, IVsUIShell pIVsUIShell, IntPtr punkDocDataIntPtr, String& strMkDocumentNew, Int32& pfCanceled)
    then i removed primary key. Table was saved successfully.
    I need to make primary key field.. how can i solve it?

    CREATE TABLE tblname (c INT NOT NULL PRIMARY KEY) 
    Have you ran the above statement successfully?  Do you create a table in VS?  
    Best Regards,Uri Dimant SQL Server MVP,
    http://sqlblog.com/blogs/uri_dimant/
    MS SQL optimization: MS SQL Development and Optimization
    MS SQL Consulting:
    Large scale of database and data cleansing
    Remote DBA Services:
    Improves MS SQL Database Performance
    SQL Server Integration Services:
    Business Intelligence

Maybe you are looking for

  • Final Cut Pro - does it come with a DVD Authoring Software

    Hey guys! I'm just planning to change my Windows to a Mac. I was looking around for a DVD Authoring Software and everyone was suggesting DVD Studio Pro. So I looked it up to get it's price but I couldn't find it at all. I would really appreciate it i

  • How to run QT and Photoshop at same time?

    Hi there, does anyone know how I can keep BOTH my Photoshop file windows AND a Quicktime movie open and running at the same time. I am trying to follow a set of QT tutorial movies that I downloaded from a podcast (and I've also tried using a Photosho

  • How to provide F4 help for a field in table control

    Hi Friends, I have requirement like below. 1.Create one custom transaction code with header and item information. 2.In item level, we will be designed table control to enter/display the data. 3.Table control’s first field will be material number and

  • 1350xi All-In-One Printing problem

    I've had a 1350xi All-in-One printer for a long time, and just recently it began printing the test page (for aligning a new cartridge) every time it is turned on.  It doesn't seem to matter if it is connected to a computer or not.  How can I change t

  • MySQL Port Access Failure

    MySQL is running. Access through /var/mysql/mysql.sock works fine. Access using MySQL port 3066 fails. How do I configure MySQL to allow access through port 3066? Appears it's simply not listening. Port is open in firewall. TIA