Results 1 to 3 of 3

Thread: Oracle - Autonumber, but not quite

  1. #1
    Join Date
    Apr 2003
    Location
    St. Louis
    Posts
    17

    Oracle - Autonumber, but not quite

    This is probably simple for you guys, but being very new to Oracle, here is my question...

    I have a number field, and it cannot be null.

    If someone wants to insert a record, and leaves that number field null, I want the number field to have the next available number inserted automatically.

    How do I make this statement?

    It's kind of like an auto number, but I still want the capability to put my own "special" number in. Basically, I don't want every record autonumbered.

    Any help would be appreciated.

    Thanks in advanced!

  2. #2
    Join Date
    Mar 2003
    Posts
    468
    sounds like you need a combination of a sequence number and trigger put on this table that will fire when an insert is done.
    the sequence number will allow you to put the "next available nubmer" and then you can put logic into the trigger for your "special" numbers.

  3. #3
    Join Date
    Nov 2002
    Location
    New Jersey, USA
    Posts
    3,932
    If you don't want duplicate number then you have to check if auto generated number is already used as a special number.

Posting Permissions

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