Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

Re: multiple queries:

by tinman (Curate)
on May 17, 2001 at 21:25 UTC ( #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 } }


Log In?

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

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (3)
As of 2020-05-25 04:26 GMT
Find Nodes?
    Voting Booth?
    If programming languages were movie genres, Perl would be:

    Results (143 votes). Check out past polls.