Results 1 to 2 of 2
  1. #1
    Join Date
    Nov 2004
    Posts
    1

    Unanswered: Problems with constraints

    I using oracle 10g and just learning. I have put in my contraints on several tables, most noteably;

    CONSTRAINT book_pk PRIMARY KEY (ISBN)

    Now i have this in a script with some other contraints and everything runs peachy keen.

    But i have created a VB.net front end to input data into my database and i can input the same value multiple times for the ISBN number through the VB.net form. I can't input mulitple ISBN values using a insert statement in sql+ (i get an error message saying i violated my primary key constrait).

    Does anyone know why my primary key constraint is not checking the data when i input using VB.net?

  2. #2
    Join Date
    May 2004
    Location
    Dominican Republic
    Posts
    721
    Did you commited the transaction ?

    Also, unless is a deferrable constraint, I see no reason why would it let you do this:
    Code:
    SQL@10g> create table t ( a number primary key );
    
    Table created.
    
    SQL@10g> insert into t ( a ) values ( 1 );
    
    1 row created.
    
    SQL@10g> insert into t ( a ) values ( 1 );
    insert into t ( a ) values ( 1 )
    *
    ERROR at line 1:
    ORA-00001: unique constraint (JMARTINEZ.SYS_C005334) violated
    
    
    SQL@10g> alter table t drop constraint SYS_C005334;
    
    Table altered.
    
    SQL@10g> alter table t add constraint pk_a primary key ( a ) initially deferred;
    
    Table altered.
    
    SQL@10g> insert into t ( a ) values ( 1 );
    
    1 row created.
    
    SQL@10g> insert into t ( a ) values ( 1 );
    
    1 row created.
    
    SQL@10g> commit;
    commit
    *
    ERROR at line 1:
    ORA-02091: transaction rolled back
    ORA-00001: unique constraint (JMARTINEZ.PK_A) violated
    
    
    SQL@10g>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •