Re: Question about report formatting

From: spademan o---[ * <steve.eckersley_at_its.lancscc.gov.uk>
Date: 12 Feb 2002 01:17:20 -0800
Message-ID: <791c29f5.0202120117.2c3338ad_at_posting.google.com>


"mario" <mario_34_at_hotmail.com> wrote in message news:<a45ou4$r2k$1_at_planja.arnes.si>...
> Hi,
>
> to set up a counter i created i sequence. ( Probably it would be better to
> declare a global variable and increase it's value, but i don't know how to
> do that (i'm still learning oracle:-)...any suggestion would be
> appriciated )
>
> So, as i said, i declared a sequence, and it's called (in the body of the
> FORMAT trigger) in this way:
>
> DECLARE
> i NUMBER;
>
> i := SEQ_FORMAT_REPORT.NEXTVAL;
>
> IF MOD(i,2)=0 THEN
> ...
> ELSE
> ...
> END IF;
>
> When i try to compile it, i get the following error message:
>
> "Table, View or Sequence reference 'SEQ_FORMAT_REPORT.NEXTVAL' not allowed
> in this context".
>
> What am i doing wrong?
>
> "Russell Kingham" <kinghams_at_bigpond.com> wrote in message
> news:Ew998.3840$BE4.10358_at_newsfeeds.bigpond.com...
> > Hi
> > Set up a counter and increment it for each time the frame fires on a page.
> > In the same format trigger check if the counter is odd/even and use the
> > built in srw.set_attr. Check in the help.
> > l8r

Hi Mario,
You cannot assign a sequence directly to a variable, instead you have to use a select statement i.e. either select it directly:

select SEQ_FORMAT_REPORT.NEXTVAL
into i
from dual;

or define your select in a cursor which is what most people do:

declare

cursor c1 is
select SEQ_FORMAT_REPORT.NEXTVAL
from dual;

i number;

begin

open c1;
fetch c1 into i;
close c1;

but as you say it would be much easier to use a global variable instead. assign the global in a pre-report trigger to 0: ":global.rowcount := 0;" and increase it every time the frame fires etc. Don't forget to erase the global after your report has run "erase('global.rowcount');".

Alternately if your report is not ordered you could just use rownum. Include rownum in your select and place it on your report to see if this is suitable.

Steve E. Received on Tue Feb 12 2002 - 10:17:20 CET

Original text of this message