Re: Auto incrementing key



chanakam2000@xxxxxxxxx wrote:
: Hi,

: Please help me,

: I'm new to oracle environment.
: I want to make a kind of auto generated primary key for my table.
: I can make auto key with sequences and triggers. But only numeric
: keys
: But i want the key with some character value.

: Ex : for student_id column my preffered value sequence is

: S-00001
: S-00002
: S-00003 ..... & so on

: I searched lot in internet. But could not find goood solution.
: Please give me some idea.

pseudo code - I doubt you really want this, but here goes anyway...

number x = my_sequence.next_value

string my_key = 'S-' || format_number('99999',x)

You need to read the docs for the real names and inputs of the various
functions.


: If this is not possible please give me idea to generate sequence like
: 00001,00002,00003....

A sequence returns a number. How you format the number is up to you.
Oracle has many functions that might help.


.



Relevant Pages

  • Re: Auto incrementing key
    ... I'm new to oracle environment. ... I want to make a kind of auto generated primary key for my table. ... If this is not possible please give me idea to generate sequence like ... separate column and leave out the hyphen. ...
    (comp.databases.oracle.misc)
  • Re: Auto incrementing key
    ... | I'm new to oracle environment. ... | I want to make a kind of auto generated primary key for my table. ... | If this is not possible please give me idea to generate sequence like ...
    (comp.databases.oracle.misc)
  • Re: Auto incrementing key
    ... | I want to make a kind of auto generated primary key for my table. ... | If this is not possible please give me idea to generate sequence like ... Let me give you one more advice: don't multipost on c.d.o.* ...
    (comp.databases.oracle.server)
  • Auto incrementing key
    ... I'm new to oracle environment. ... I want to make a kind of auto generated primary key for my table. ... I can make auto key with sequences and triggers. ... If this is not possible please give me idea to generate sequence like ...
    (comp.databases.oracle.server)
  • Auto incrementing key
    ... I'm new to oracle environment. ... I want to make a kind of auto generated primary key for my table. ... I can make auto key with sequences and triggers. ... If this is not possible please give me idea to generate sequence like ...
    (comp.databases.oracle.misc)

Loading