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:
You should of course check that the two input parameters are valid before submitting the SQL request.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. }
Michael
|
---|
In Section
Seekers of Perl Wisdom