Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re: Re: Re: DBI SQL statement in while loop

by mpeppler (Vicar)
on Dec 03, 2002 at 23:41 UTC ( [id://217372]=note: print w/replies, xml ) Need Help??


in reply to Re: Re: DBI SQL statement in while loop
in thread DBI SQL statement in while loop

Ah. Well in that case you'll have to move the prepare() into the loop (or use do()) and use interpolation (with the usual caveats about NULLs, etc.)

The naive version would look like this:

while (<>) { my $quantity = param("quantity"); my $gross_sales = param("gross_sales"); my $sql = qq/ insert into transaction_details(quantity, gross_sales) values($quantity, $gross_sales) /; my $rv = $dbh->do($sql); # check return value, etc. }
You should of course check that the two input parameters are valid before submitting the SQL request.

Michael

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (5)
As of 2024-04-23 17:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found