Perl Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesPerl Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
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  
Old November 14th, 2000, 04:02 AM
chrisdice4 chrisdice4 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2000
Location: Cape Town, WP, South Africa
Posts: 39 chrisdice4 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 8
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;

}

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPerl Programming > insert into in a loop


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway