Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

dbi: selectrow_arrayref

by perlthirst (Scribe)
on Dec 31, 2008 at 12:46 UTC ( #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.

Comment on dbi: selectrow_arrayref
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
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);

Log In?
Username:
Password:

What's my password?
Create A New User
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? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (4)
As of 2014-07-31 00:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (242 votes), past polls