Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

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

In reply to Re: multiple queries: by tinman
in thread multiple queries: by anjaana78

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (6)
As of 2024-04-25 11:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found