Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Selecting from a sequence based on a variable name?
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
![]() |
![]() |