Re: How to (MyVariable := MySequence.currval)

From: Matt B. <mcb_at_fightspam.sd.znet.com>
Date: 2000/06/27
Message-ID: <slj3hoi5jev66_at_corp.supernews.com>#1/1


"Greg" <actiris_at_loxinfo.co.th> wrote in message news:395981F0.71B072D9_at_loxinfo.co.th...
> Need to save the current value of a sequence in a variable to use it
> later.
>
> declare
> MyVariable number;
>
> MyVariable := MySequence.currval;
>
> does not work
>
> PLS-00357: Table,View Or Sequence reference 'BGV.SEQ_NAME_ID.CURRVAL'
> not allowed in this context
> ============
> The help on PLS-00357
> PLS-00357 Table,View Or Sequence reference 'string' not allowed in this
> context
> Cause: A reference to database table, view, or sequence was found in an
> inappropriate context. Such references can appear only in SQL statements
> or (excluding sequences)
> in %TYPE and %ROWTYPE declarations. Some valid examples follow:
> ============
>
> I guess the declare is wrong.....
> How to do that
> Thanks Greg

No - it's right. I believe the problem is that sequences have to be part of a select statement:

declare
  MyVariable number;
begin
  select MySequence.currval
  into MyVariable
  from dual;
  do_other_stuff_here;
end;

-Matt Received on Tue Jun 27 2000 - 00:00:00 CEST

Original text of this message