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

Thread: Creating a Unique Identifier of a Sequence and a Character

  1. #1
    Join Date
    Nov 2002
    Posts
    30

    Question Creating a Unique Identifier of a Sequence and a Character

    Hi all,

    I'm attempting to create a unique identifier field in a table that consists of a character (representing the Oracle instance) and the value of a sequence. In essence, when a value is inserted into the table by an application, the unique field value will be:

    Character + nextval from a sequence.

    Thus, I'm trying to create a sequence that contains the character and the numbers generated by the sequence.

    Does anyone know how this can be done?

    Thanks!

  2. #2
    Join Date
    Sep 2002
    Location
    England
    Posts
    7,334
    create a before insert trigger, supply the :NEW as 'character '||sequence.nextval

  3. #3
    Join Date
    Jun 2006
    Posts
    259
    Sounds like a concatenated field... Don't do this, its really poor data modelling.

    Just use 2 fields. Inserting the db name/instance id as one value and the Sequence into a seperate fields...
    If you need the data concatenated use a view or select it as field1||field2 ...

    Just my .02

  4. #4
    Join Date
    Nov 2002
    Location
    Geneva Switzerland
    Posts
    3,142
    . . . and with 2 fields you can still specify (col1, col2) as primary key or unique index.
    "The power of instruction is seldom of much efficacy except in those happy dispositions where it is almost superfluous" - Gibbon, quoted by R.P.Feynman

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