Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical

Re: Re: DBI SQL statement in while loop

by peppiv (Curate)
on Dec 03, 2002 at 21:32 UTC ( #217352=note: print w/replies, xml ) Need Help??

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

Thanks Michael. But in using FreeTDS and DBI Sybase (thank you) I haven't been able to use placeholders. My apologies for not listing the setup: Apache/Linux/Perl -> Win2K/SQL Server 7.0
  • Comment on Re: Re: DBI SQL statement in while loop

Replies are listed 'Best First'.
Re: Re: Re: DBI SQL statement in while loop
by mpeppler (Vicar) on Dec 03, 2002 at 23:41 UTC
    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.


Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://217352]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (3)
As of 2017-11-19 00:27 GMT
Find Nodes?
    Voting Booth?
    In order to be able to say "I know Perl", you must have:

    Results (278 votes). Check out past polls.