DBAsupport.com Forums - Powered by vBulletin
Results 1 to 3 of 3

Thread: Update or Insert?

  1. #1
    Join Date
    Oct 2003
    Location
    Pune, India
    Posts
    1

    Question Update or Insert?

    Hi,

    I am facing a classic problem of determining whether to use Update or Insert.

    Wondering if there is any good way of doing it in one shot using Oracle 8i.

    I have a requirement where I don't know whether data exists in the table or not. For this currently I am firing a Select count(*) and if there are any rows in the database then I form an Update query otherwise an Insert.

    This seems to be very orthodox way and not a good option.

    However if someone has thought of any good workable work around for such scenario please share it with us.

    Thanks in Advance.

    Regards,
    SP

  2. #2
    Join Date
    Oct 2002
    Posts
    807
    > However if someone has thought of any good workable work around for such scenario please share

    9i - Merge / upsert statement.
    8i and lower - There's really no work around. You gotta write code. plsql or whatever.

  3. #3
    Join Date
    Nov 2000
    Location
    greenwich.ct.us
    Posts
    9,092

    Re: Update or Insert?

    Originally posted by sp_ojha

    I have a requirement where I don't know whether data exists in the table or not. For this currently I am firing a Select count(*) and if there are any rows in the database then I form an Update query otherwise an Insert.
    Use your exceptions. Do a plain insert, if DUP_VAL_ON_INDEX is fired, update.
    Jeff Hunter

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