peppiv has asked for the wisdom of the Perl Monks concerning the following question:
Here's something I haven't been able to figure out (but have to, urgently).
I have this e-commerce package on our site and since I'm running the CC verification through a socket program I wrote, I also want to send this information to a DB for reporting purposes (the commerce package sucks, but alas, I don't get to make purchasing recs).
Here's the problem: The commerce program sends me transaction details through a form. Their form sends (1) transaction info - name, time, etc. (2) and transaction details - quantity 1 of product B, quantity 2 of product C, etc. Their form iterates through the transaction details, if there's more than one item per transaction, and sends the data to my program. The data is sent through set variables but as the program iterates over to the next item, it sends the info again to the same variables. Hence, if I do a single DBI INSERT I'm only collecting info on the Last item.
I thought that using a while loop might solve this problem but I'm not sure if it's the right thing to do or I've just totally screwed it up :0
inoperative code to follow
Any suggestions or quick pointers to where I'm falling down would be appreciated.
Supa Thanx, for any help
peppiv
I have this e-commerce package on our site and since I'm running the CC verification through a socket program I wrote, I also want to send this information to a DB for reporting purposes (the commerce package sucks, but alas, I don't get to make purchasing recs).
Here's the problem: The commerce program sends me transaction details through a form. Their form sends (1) transaction info - name, time, etc. (2) and transaction details - quantity 1 of product B, quantity 2 of product C, etc. Their form iterates through the transaction details, if there's more than one item per transaction, and sends the data to my program. The data is sent through set variables but as the program iterates over to the next item, it sends the info again to the same variables. Hence, if I do a single DBI INSERT I'm only collecting info on the Last item.
I thought that using a while loop might solve this problem but I'm not sure if it's the right thing to do or I've just totally screwed it up :0
inoperative code to follow
I get no errors. I just know that I'm not passing any data to this table (I pass other data to another table earlier in the program so I'm sure the DB connection works). Can I accept variables passed through a form to this script in a while statement?my $sql2 = qq/ INSERT INTO transaction_details (quantity, gross_sales) VALUES ($ +quantity, convert (money, $gross_sales)) /; while (<>) { my $quantity = param("quantity"); $quantity = $dbh->quote( $quantity ); my $gross_sales = param("gross_sales"); $gross_sales = $dbh->quote( $gross_sales ); my $rv = $dbh->do( $sql2 ); }
Any suggestions or quick pointers to where I'm falling down would be appreciated.
Supa Thanx, for any help
peppiv
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: DBI SQL statement in while loop
by chromatic (Archbishop) on Dec 03, 2002 at 21:44 UTC | |
by mpeppler (Vicar) on Dec 03, 2002 at 23:48 UTC | |
Re: DBI SQL statement in while loop
by mpeppler (Vicar) on Dec 03, 2002 at 21:27 UTC | |
by peppiv (Curate) on Dec 03, 2002 at 21:32 UTC | |
by mpeppler (Vicar) on Dec 03, 2002 at 23:41 UTC | |
Re: DBI SQL statement in while loop
by UnderMine (Friar) on Dec 03, 2002 at 21:42 UTC | |
Re: DBI SQL statement in while loop
by rbc (Curate) on Dec 03, 2002 at 21:37 UTC |
Back to
Seekers of Perl Wisdom