Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: Need help to correct a simple script

by space_monk (Chaplain)
on Jan 07, 2013 at 16:08 UTC ( #1012053=note: print w/replies, xml ) Need Help??


in reply to Need help to correct a simple script

The SQL needs to be declared in the loop, as you're changing the variable $count each time. Consider the more idiomatic
foreach my $count (1..$tables) { my $sql =<<EOF; .... EOF die ("Failed to insert row: " . DBI->errstr) if (!($dbh->do ($sql) +)); }

Unfortunately you can't prepare and execute this statement with bound variables, as the table name is formed from one of the variables.

A Monk aims to give answers to those who have none, and to learn from those who know more.

Replies are listed 'Best First'.
Re^2: Need help to correct a simple script
by terrykhatri531 (Novice) on Jan 07, 2013 at 18:36 UTC
    Hi

    Thank you for your quick responses, I adjusted my script accordingly and now it works like a charm.

    Rgds

    Terry

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1012053]
help
Chatterbox?
[shmem]: Lady_Aleena: that's up to you. I only wanted to show you a path that might be more comforting than command line grep ;-)
[Lady_Aleena]: shmem, I don't think any of my modules could be converted to OO. They are too procedural.
[Lady_Aleena]: Now I will see if my perl-fu is as bad as I think it is.
[shmem]: ah, geany uses its own idea of tags. Ah well...
[Lady_Aleena]: My perl-fu is bad.

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (10)
As of 2017-04-27 12:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I'm a fool:











    Results (506 votes). Check out past polls.