Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Selecting from a sequence based on a variable name?

Selecting from a sequence based on a variable name?

From: Alexander Bisset <alexander_at_bisset.demon.co.uk>
Date: Sun, 23 Aug 1998 22:20:15 +0100
Message-ID: <903907215.10438.0.nnrp-05.9e984e06@news.demon.co.uk>


I have several sequences all with the same starting name and only the last part varying e.g.:

sequence_1997
sequence_1998
sequence_1999

I want to write a function similar to the following

function get_sequence(seqYear number) return number is

    strSeqName varchar2(13);
    intSeqNum number(5);
begin

    strSeqName := 'sequence_' || to_char(seqYear);     select strSeqName.nextval into intSeqNum from dual;     return intSeqNum;
end;

This does not work, but hopefully you get the idea. I need some method of selecting the next sequence number from one of many sequences based on a variable passed into the function.

Thanks in advance Received on Sun Aug 23 1998 - 16:20:15 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US