conditional insert
DBAsupport.com Forums - Powered by vBulletin
Results 1 to 5 of 5

Thread: conditional insert

Hybrid View

  1. #1
    Join Date
    Jan 2001
    Posts
    2,828

    Talking

    Hello all

    In a table (with 2 cols) i want to insert 2 values say
    "33" and
    "hrishi"( 1 record )
    only if the same values does not exist ie.."33" and
    "hrishi" (1 record ).

    can this be done through a single sql statement.

    regards
    Hrishy



  2. #2
    Join Date
    Jun 2000
    Location
    Madrid, Spain
    Posts
    7,447
    you mean PK/UNIQUE behaviour without setting constraint?

  3. #3
    Join Date
    Jan 2001
    Posts
    2,828

    Talking

    Hello Pando

    Nope i would first like to check whaether the record which i want to insert exists if no then i would like to insert this record using a single insert statement is this possible.

    regards
    Hrishy

  4. #4
    Join Date
    Aug 2001
    Location
    Waterloo, On
    Posts
    547
    You could use a composite primary/unique key for the 2 columns in question.

    Raminder Singh

    Oracle Certified DBA: Oracle 8i, 9i


    Mail me at raminderahluwalia@rediffmail.com.

  5. #5
    Join Date
    Nov 2000
    Location
    greenwich.ct.us
    Posts
    9,092
    You could use an instead-of insert trigger to check your data before you insert into the table...
    Jeff Hunter
    marist89@yahoo.com
    http://marist89.blogspot.com/
    Get Firefox!
    "I pledge to stop eating sharks fin soup and will not do so under any circumstances."

Posting Permissions

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


Click Here to Expand Forum to Full Width