Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

dbi: selectrow_arrayref

by perlthirst (Scribe)
on Dec 31, 2008 at 12:46 UTC ( [id://733455]=perlquestion: print w/replies, xml ) Need Help??

perlthirst has asked for the wisdom of the Perl Monks concerning the following question:

As per my understanding we can pass statements (select) to a selectrow_arrayref which will return the first row of data from the statement. But in the manual page there is a statement

"The $statement parameter can be a previously prepared statement handle, in which case the "prepare" is skipped"

Is it giving a meaning that we can pass statement handle to selectrow_arrayref? Is this understanding correct? But if we pass the statement handle to selectrow_arrayref it is throwing error. then what is the meaning of the above quoted string?

Kindly clarify.

Replies are listed 'Best First'.
Re: dbi: selectrow_arrayref
by tinita (Parson) on Dec 31, 2008 at 13:34 UTC
    But if we pass the statement handle to selectrow_arrayref it is throwing error.
    Which error? Please post the code which produces the error and the exact error message.
    The following code works for me:
    my $dbh = DBI->connect("dbi:...", $user, $pass); my $sql= "select ... from ..."; my $sth = $dbh->prepare($sql); my $row = $dbh->selectrow_arrayref($sth);
Re: dbi: selectrow_arrayref
by Seqi (Acolyte) on Dec 31, 2008 at 13:03 UTC
    you are using:
    $dbh->selectrow_arrayref
    instead of:
    selectrow_arrayref($sth)
    right? edit: corrected the calls(?) what I use in a program of mine:
    $dbh->selectrow_hashref($sql);
    hope this manages to give a hint in the right direction
Re: dbi: selectrow_arrayref
by bradcathey (Prior) on Dec 31, 2008 at 13:34 UTC

    Required reading--you'll want to bookmark this one.

    —Brad
    "The important work of moving the world forward does not wait to be done by perfect men." George Eliot

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://733455]
Approved by andreas1234567
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (4)
As of 2024-04-20 00:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found