in reply to DBI SQL statement in while loop
Off hand I think this calls for placeholders - something like:
This should handle all quoting (if any is necessary) and should also handle the conversion to "money" (which makes me think that this is a Sybase or MS-SQL database server...)my $sql2 = qq/ INSERT INTO transaction_details (quantity, gross_sales) VALUES (?, ?) /; my $sth = $dbh->prepare($sql2); while (<>) { my $quantity = param("quantity"); my $gross_sales = param("gross_sales"); my $rv = $sth->execute($quantity, $gross_sales); # Handle error if $rv is false... }
Michael
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Re: DBI SQL statement in while loop
by peppiv (Curate) on Dec 03, 2002 at 21:32 UTC | |
by mpeppler (Vicar) on Dec 03, 2002 at 23:41 UTC |
In Section
Seekers of Perl Wisdom