in reply to Re: Executing multiple mysql commands in a single execute() call.
in thread Executing multiple mysql commands in a single execute() call.

I'm not sure I understand your questions, and you may have misunderstood mine. I want to set t_id from one table and then use it in many following queries to other tables. I could join or use nested selects in all the following queries, but there's no reason to do all that work every time, when the value of t_id stays the same!

I checked out eval and it seems to be more complicated than what I need. I just want to set a variable and use it, after all.

  • Comment on Re^2: Executing multiple mysql commands in a single execute() call.

Replies are listed 'Best First'.
Re^3: Executing multiple mysql commands in a single execute() call.
by Anonymous Monk on May 30, 2012 at 11:42 UTC

    Why cannot you take the results from your SELECT Team_ID query, and put it into a Perl variable? You can then, without much trouble, use it in all your further queries by passing it to $sth->execute($team_id, $other, $params)

    What Corion was wondering about is, if you want to put multiple queries into one string and execute it, how would you read the results? How would you distinguish between the results of one query and the next one? (I don't think most database interfaces support multiple result sets.) How would jamming all the queries into a single string help readability?

    We'd like to see some code from you, especially on how you call the database. You are using prepared queries, aren't you?

      why not you push value in variable( scalar,array- if multiple) and then use further. This is easy step to go ahead. For example.
      my $result = qx!kfsql -S Servername -D database -F e -s , -c \"select +field1 from test where criteria = "C" and some_date \!= $processdate +order by field_time desc\"!; if want to push in array then.. chomp $result; my @array= ($result=~ s/\"//g); this will push all result value into variable and you can use through +out in program.
      Hope this will help.