Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.tools -> Re: OAS plsql formatting question...
"Matt" <zagnimp_at_aom.bt.co.uk> wrote in message
news:3AEEFB2C.8DAA35_at_aom.bt.co.uk...
> Hi,
>
> Heres a formatting problem... for OAS...
>
> CURSOR c_odds IS
> SELECT misc_data
> FROM test.os_data;
>
> .......
>
> FOR r_odds IN c_odds LOOP
> htp.p(' ' || r_odds.misc_data || ',');
> END LOOP;
>
> ....
>
> Select * from odds;
>
> 10
> 20
> 40
> 60
> 90
> 100
>
>
> However as you can exepect all is going well the data is
> returned apart from one thing....
>
> The cursor returns the data correctly with the ',' at the
> end of each row it has selected.
>
> 10,
> 20,
> 40,
> 60,
> 90,
> 100,
>
> But although this is correct the last row also contains a ',' too
> (this I do not want).
>
> How can I select all the rows to have a ',' after each one _apart_ from
> the last one which should only have a number and no ','
>
> To look like this
>
> 10,
> 20,
> 40,
> 60,
> 90,
> 100
>
> Any help would be great
>
> Regards
>
> Matt
>
>
>
>
>
Usually it is the most easy to treat the first one differently, as you know
which record is the first
so you would
open c_odds;
fetch c_odds into r_odds; -- which now has to be defined seperately
--- print without quote, and without newline r_odds
fetch c_odds into r_odds;
while c_odds%found loop
print the newline
print r_odds with quote, without newline
fetch c_odds into r_odds;
end loop;
print the newline.
Hth,
Sybrand Bakker, Oracle DBA Received on Tue May 01 2001 - 13:24:49 CDT