http://www.perlmonks.org?node_id=362024


in reply to bind variables with array

I see two three potential problems with your code:

Apart from that, passing an array of parameters is a legitimate way of calling execute, as you can see in DBI docs and DBI Recipes.

Can you build a simple and short test case, with sample data, so we can see where and how your script fails?

 _  _ _  _  
(_|| | |(_|><
 _|   

Replies are listed 'Best First'.
Re^2: bind variables with array
by hakkr (Chaplain) on Jun 08, 2004 at 11:27 UTC
    Thanks yes that was just a rough example , I found my problem !! If you call execute(()); that is with a blank array you get an error so I had to put in a check to prevent it getting called when no placeholders are passed in
    my $res = (defined @$vars) ? $sth->execute(@$vars) : $sth->execute;

    Thanks for the pointer to the docs looks like execute(@) justs calls bind_param() for each value in the array so it does work.