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 -> Re: Selecting from a sequence based on a variable name?

Re: Selecting from a sequence based on a variable name?

From: Jonathan Gennick <gennick_at_worldnet.att.net>
Date: 24 Aug 1998 03:38:34 GMT
Message-ID: <35eddd5b.25411625@netnews.worldnet.att.net>


On Sun, 23 Aug 1998 22:20:15 +0100, "Alexander Bisset" <alexander_at_bisset.demon.co.uk> wrote:

>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.

You need to use the DBMS_SQL package. It's documented in the Application Developer's Guide. Essentially, it lets you build up dynamic SQL statements as character strings, and then execute same.

regards,

Jonathan Gennick Received on Sun Aug 23 1998 - 22:38:34 CDT

Original text of this message

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