Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: multiple queries:

by tinman (Curate)
on May 17, 2001 at 21:25 UTC ( [id://81306]=note: print w/replies, xml ) Need Help??


in reply to multiple queries:

I'm not sure what the error from your query is... so, there are several assumptions that I will make..

Assuming there is a dependency between the first query and the second (ie: the second query uses part of the result from the first query), just perform your validation before calling the second query..

Some things that I see in your code, calling prepare repeatedly is not efficient, consider using placeholders in your query code, read this node if you're not sure about placeholders...also, it does not appear that you are using the -w switch and running your code under strict.. consider doing this, it can save you lots of debugging effort, and its not too hard to incorporate either...

So, your code can look like,

my $handle = $syb->prepare($query); while(my @row = $select->fetchrow_array()) { # assuming that $row[0] is what you want to use in the # next query if($row[0] == 'ok') # it passes validation, yay { $handle->execute($row[0]); # fetch all the rows here if you want } else { # this is how you trap errors, leave this blank if you wi +sh } }

HTH

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (5)
As of 2024-03-29 11:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found