Thanks all, sorry for the trouble. I think I need to read more clearly next time. Chris

--
-------------------------------
Just Your Friendly Neighborhood
_SPIDEY_


Hardy Merrill wrote:


Ronald J Kimball [EMAIL PROTECTED] wrote:


On Tue, Jun 24, 2003 at 03:42:16PM -0400, Hardy Merrill wrote:


From 'perldoc DBI':

      "fetchrow_array"
           @ary = $sth->fetchrow_array;

          An alternative to "fetchrow_arrayref". Fetches the next row of data
          and returns it as a list containing the field values.  Null fields
          are returned as "undef" values in the list.

Notice that you are accepting the results of $sth->fetchrow_array
into a *scalar* $sr_id - using fetchrow_array that should be
an array. When you use a scalar in list context, the scalar
ends up containing the *number* of array elements.


Don't confuse an array in scalar context with a function call in scalar
context.  A function call in scalar context could return the number of
elements, or the first element, or a ref to an array of elements, or
something else; it's up to the author of the function.

In this case, the behavior of fetchrow_array() in a scalar context is
undefined:

If called in a scalar context for a statement handle
that has more than one column, it is undefined whether
the driver will return the value of the first column
or the last. So don't do that. Also, in a scalar
context, an undef is returned if there are no more
rows or if an error occurred. That undef can't be
distinguished from an undef returned because the first
field value was NULL. For these reasons you should
exercise some caution if you use fetchrow_array in a
scalar context.



Thanks for catching that Ronald - my bad :-/


Hardy







-----------------------------------------
The information contained in this message may be privileged, confidential, and protected from disclosure. If the reader of this message is not the intended recipient, or any employee or agent responsible for delivering this message to the intended recipient, you are hereby notified that any dissemination, distribution, or copying of this communication is strictly prohibited. If you have received this communication in error, please notify us immediately by replying to the message and deleting it from your computer.


Thank you. Paychex, Inc.

Reply via email to