Re: DBI: selectrow_array() return first column when called in list context

Chad Wallace <[email protected]>
Newsgroups gmane.comp.lang.perl.modules.dbi.general
Organization The Lodging Company
Message-ID <[email protected]>
On Mon, 23 Dec 2013 22:28:55 +0000
Mimi Cafe <[email protected]> wrote:

> This helped.
> 
> > On 23 Dec 2013, at 15:28, Bruce Johnson
> > <[email protected]> wrote:
> > 
> > 
> >> On Dec 23, 2013, at 2:30 AM, [email protected] wrote:
> >> 
> >> The SQL query is the same in both cases, and as can be seen, the
> >> query is expected to return two columns (user and perm), but
> >> selectrow_array() returns undef for the second column (perm in
> >> this case).
> >> 
> >> my ($x, $y)  = $dbh->selectrow_array(qq{SELECT user,perm FROM
> >> access WHERE token=\'Tt9VpStL4xADSDJQtd4AkM
> >> c6cVi66Mwmr9pMcCRgO4NVJ\'})|| die
> >> "Could not query database:  $DBI::errstr\n";
> >> 
> >> In the above, $y is undef (or blank) although MySQL has values for
> >> both (user and perm) columns.
> > 
> > The problem, which Martin correctly noted, is that  selectrow_array
> > returns a single thing, an array containing the returned data.
> > 
> > my ($x, $y)  = $dbh->selectrow_array(SQL);
> > 
> > is giving you a pointer to the returned array, $x, and an undef $y.

Hold on...  Am I missing something?  

What you seem to be saying, Bruce, is that selectrow_array() is exactly
the same as selectrow_arrayref(). I am certain that's not the case.
I've used both methods many times, and they are different.

Is "a pointer to the returned array" not the same as "an array
reference"?




-- 

C. Chad Wallace, B.Sc.
The Lodging Company
http://www.lodgingcompany.com/
OpenPGP Public Key ID: 0x262208A0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.