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

Re: More DBI Problems!!!

by repson (Chaplain)
on Apr 23, 2001 at 14:47 UTC ( #74677=note: print w/replies, xml ) Need Help??

in reply to More DBI Problems!!!

It would help if you told us which line 50 was in the future.

However, I think the problem is in

The method selectrow_array is for performing a full prepare, execute and returning the array. The parameter is an sql string, not a query object.

What you probably meant was:

Which returns a single row of the prepared and executed query it is call on.

Replies are listed 'Best First'.
Re: Re: More DBI Problems!!!
by chipmunk (Parson) on Apr 24, 2001 at 08:00 UTC
    I think repson must be right that you meant to use $query->fetchrow_array instead of $dbh->selectrow_array($query).

    However, the $dbh->select... methods can take an already prepared statement handle as the first argument. This allows you to prepare the statement once ahead of time, and then execute it with select... many times. For example:

    my $sth = $dbh->prepare(<<EndOfSQL); SELECT name FROM item WHERE id = ? EndOfSQL while (<>) { chomp; if (($name) = $dbh->selectrow_array($sth, {}, $_)) { print "$_ => $name\n"; } else { print "$_ not found\n"; } }

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://74677]
[harishnv]: have a question
[shmem]: good for you. Is it a secret?

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (11)
As of 2018-02-19 16:18 GMT
Find Nodes?
    Voting Booth?
    When it is dark outside I am happiest to see ...

    Results (266 votes). Check out past polls.