Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re^3: Global symbol "$prepare" requires explicit package name

by soonix (Canon)
on Sep 19, 2019 at 07:48 UTC ( #11106362=note: print w/replies, xml ) Need Help??


in reply to Re^2: Global symbol "$prepare" requires explicit package name
in thread Global symbol "$prepare" requires explicit package name

In addition to what poj said, instead of
$sth2 = $dbh->prepare("update $what$ever");
to see what's going on, write
my $sqltext = "update $what$ever"; print qq(SQL query is: "$sqltext"); $sth2 = $dbh->prepare($sqltext);
Perhaps there's a stray question mark in your $date_new

Replies are listed 'Best First'.
Re^4: Global symbol "$prepare" requires explicit package name
by tukusejssirs (Beadle) on Sep 19, 2019 at 08:09 UTC

    Indeed poj, it works now.

    Could you tell me please, why does it need to have ? (I believe these question marks are those placeholders from the error message) in the prepare part? And why I could not run $dbh->execute("update $schema.$table set $date_col = $date_new where $where_col = 1;") or die; directly? In this particular code I donít need neither $sth handle for reuse nor the placeholders to re-execute the code (as the variables will be all the same in all the loop cycles).<\p>

    Thank you very much!

      I donít need neither $sth handle for reuse nor the placeholders to re-execute the code

      Placeholders are not just beneficial for handle re-use. See eg. Answer: What are placeholders in DBI, and why would I want to use them? and the related allusions in Databases made easy. Perhaps your data would otherwise have been incorrectly quoted or incorrectly escaped or be of the wrong type or be in an inadmissible format, etc. Use placeholders or be prepared to explain and justify precisely why you have chosen not to.

      What you're asking for, here, is do.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (4)
As of 2020-10-20 20:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My favourite web site is:












    Results (210 votes). Check out past polls.

    Notices?