Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: brain dead FOR LOOP gotcha

Re: brain dead FOR LOOP gotcha

From: Mark C. Stock <mcstockX_at_Xenquery>
Date: Fri, 6 May 2005 07:14:26 -0400
Message-ID: <oYKdnSSQTNsOzObfRVn-rw@comcast.com>

"Noons" <wizofoz2k_at_yahoo.com.au> wrote in message news:1115341213.597158.30380_at_g14g2000cwa.googlegroups.com...
> Mark C. Stock wrote:
>> been pounding my head on my desk trying to figure out why a test
> script was
>> not working -- it was just a simple loop like this one that called a
> stored
>> procedure with the value returned by the for loop
>>
>> SQL> declare
>> 2 n_dummy number;
>> 3 n_count number default 0;
>> 4 begin
>> 5 for r1 in (
>> 6 select deptno
>> 7 into n_dummy
>> 8 from dept
>> 9 )
>> 10 loop
>> 11 n_count := n_count + 1;
>> 12 dbms_output.put_line(n_count ||') '||n_dummy);
>> 13 end loop;
>> 14 end;
>> 15 /
>>
>> Results:
>> 1)
>> 2)
>> 3)
>> 4)
>>
>> it would run, but always appear to return NULL for the selected value
> ...
>> can you spot the problem? when i finally did i wasn't sure who was
> more
>> brain-dead, me or pl/sql.
>>
>
> Of course, one might demand you reference the contents of the cursor
> appropriately? As in:
> dbms_output.put_line(n_count ||') '||r1.deptno);

of course - but shouldn't notepad had known that's what i wanted when i pasted in my code snippet ? ;-)

>
> But you're right: a syntax error would have been nice.
> <gripe>Particularly from a piece of software that is smart-arsed
> enough to tell me I forgot the "from" when I mistype it as "form"
> but dumb enough not to correct it for me... (/gripe>
>

i'm still waiting for UDPATE to be added to the SQL standard (or would that be QSL?)

++ mcs Received on Fri May 06 2005 - 06:14:26 CDT

Original text of this message

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