|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now! |
|
#1
|
|||
|
|||
|
Below is a section of my script, I want it to loop through the select query and insert the results into a temp table that has an incremented id, only what happens is that it only inserts 1 row when there should be over 100; does anybody know why, or can you only insert 1 row at a time hence the insert into statement does not work in a loop.
Any ideas would be most welcome $sth = $dbh->prepare("select Customer.CustID, Customer.CustName, Customer.Trade, Customer.SalesPersonnelID FROM Customer "); $sth->execute; while (@row=$sth->fetchrow) { print "<tr><td>$i</td><td>$row[1]</td><td>$row[2]</td><td>$row[3]</td></tr>"; $sth = $dbh->do("INSERT INTO temp1 (Rangeid,SalesPersonnelID, CustName, Trade ) VALUES ($i, $row[3], '$row[1]', '$row[2]')") | | die print "problem with the insert query"; $i = $i+1; } |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Perl Programming > insert into in a loop |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|