Re: Simple PL/SQL question about sequences

From: Alvin W. Law <alaw_at_us.oracle.com>
Date: 1996/11/15
Message-ID: <328D21C7.6E7F_at_us.oracle.com>#1/1


Jim Mc Ree wrote:
>
> I want to implement a PL/SQL function where I pass in the name of a
> sequence and get back the next value in the sequence. I am brand-new to
> Oracle and PL/SQL and haven't found a way to do this (that compiles) on
> my own, so I thought the net would have the answer. It seems like such
> a simple problem. Here's what I currently have:
>
> ---------------------------
> CREATE OR REPLACE FUNCTION read_counter (counter_name in VARCHAR2)
> RETURN NUMBER IS
> counter NUMBER;
>
> BEGIN
>
> SELECT :counter_name.nextval INTO counter FROM dual;
> RETURN (counter);
>
> END;
> /
> ----------------------------
>
> The above function does not compile. What am I doing wrong in syntax or
> my approach?

You need to use dynamic SQL since sequence names are not bindable. Received on Fri Nov 15 1996 - 00:00:00 CET

Original text of this message