Hi,

the explanation is quite simple. In both cases last run with 'while' sets
@tvalue to undef  (Nothing more to fetch). In the second case last
'non-empty' result was saved in the @dummy array. And it's not overwritten
because last check with undefined result doesn't go into while loop.

Reg's
Oleg

> -----Original Message-----
> From: Jones Robert Contr 81 CS/SCK
> [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, August 23, 2001 4:43 PM
> To: [EMAIL PROTECTED]
> Subject: Looping Scenario
>
>
>
>      This is an interesting scenario that had me going for
> hours to figure
> out.  I've cut-n-pasted the relevent sections below in a
> brief edited format
> for simplicity.
>
>  $sth=$rbh->prepare("SELECT * from table where field='$value[1]'")
>  $sth->execute;
>  while (@tvalue=$sth->fetchrow_array)
>    { $match++; }
>  print "@tvalue\n";
>
>      This caused the output to print nothing ..... But when I
> altered it as
> so ...
>
>  $sth=$rbh->prepare("SELECT * from table where field='$value[1]'")
>  $sth->execute;
>  while (@tvalue=$sth->fetchrow_array)
>    { @dummy = @tvalue; }
>  print "@dummy\n";
>
>      Then the results would show up.  This seems a little
> confusing as it
> implies to me that the scope of @tvalue is only local to the
> while loop.
>
>      This is being run on Oracle 8.1.5 and Oracle 8.1.7 with
> Perl build 522,
> DBI 1.14, DBD-Oracle 1.03 on Windows NT platforms.
>
> Robert E. Jones, BSCS, BSP
> 81 CS/SCK, Keesler AFB
>

Reply via email to