Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight

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.

Comment on Re: Need help to correct a simple script
Download Code
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

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



Log In?

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

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (5)
As of 2016-02-08 22:31 GMT
Find Nodes?
    Voting Booth?

    How many photographs, souvenirs, artworks, trophies or other decorative objects are displayed in your home?

    Results (286 votes), past polls