in reply to DBI SQL statement in while loop

You're requesting the same form variables on each iteration. Besides that, interpolation occurs where you declare and assign the SQL statement -- not when you "re-assign" to $quantity and $gross_sales. Print $sql2 in the loop to see.

Placeholders are definitely the way to go -- though I've never used FreeTDS, I know that DBI emulates placeholders for databases that don't support them natively.

As for iterating over form variables, you're looping over the contents of the files named in @ARGV, or STDIN, which isn't what you want. I bet your loop contents aren't being executed once.

You need to figure out how to iterate over your form variables. If they have programmatic names, that's one way. If they have the same name, you'll have to read their contents into arrays. It's hard to say without seeing the HTML form.

Replies are listed 'Best First'.
Re: Re: DBI SQL statement in while loop
by mpeppler (Vicar) on Dec 03, 2002 at 23:48 UTC
    though I've never used FreeTDS, I know that DBI emulates placeholders for databases that don't support them natively
    Unfortunately DBI doesn't - however some drivers emulate placeholders (for example DBD::MySQL).

    In the case of DBD::Sybase it is written with the Sybase libraries in mind, and in that situation will handle placeholders just fine. The problem is that FreeTDS isn't (yet) a complete implementation of the TDS protocol, and the reverse engineering problem is compounded by the fact that Sybase and MS have implemented placeholder handling differently.

    However, there is hope - I understand that the next release of FreeTDS may support placeholders correctly.

    Michael