Prev: QtRuby 1.4.7
Next: Send over raw socket?
From: Luis Lebron on 6 Nov 2006 13:50 I have a ruby script that inserts data into a SQL Server Express database. The inserts work but I keep getting errors like the following "WARNING: STMT 0x2954f50 was not dropped before garbage collection." Here's the script ========================== require 'odbc' c=ODBC::connect('SMD') t1 = Time.now aFile = File.open("C://temp/DMERECAP.SDF") aFile.each_line do |line| if $. < 11 q =c.prepare("Insert into DMERECAP(recptlo,datepaid,invoicenum,dolapplied,payername,hcpc,servdatepd,patnum) values ('#{line[0..6].squeeze(" ")}' ,'#{line[7..16].squeeze(" ")}', '#{line[17..28].squeeze(" ")}', '#{line[29..40].squeeze(" ")}', '#{line[48..87].squeeze(" ")}', '#{line[88..92].squeeze(" ")}', '#{line[145..154].squeeze(" ")}', '#{line[138..145].squeeze(" ").to_i}')") q.execute() end end puts "Import complete." puts Time.now-t1 if c c.disconnect end ============ Any help would be appreciated. thanks, Luis -- Posted via http://www.ruby-forum.com/.
From: Ben Gribaudo on 6 Nov 2006 15:38 Hi Luis, I asked Christian Werner about this in the past. He told me that these are internal warnings intended to remind the lazy programmer to close/drop his ODBC statements. If you don't do so, their cleanup doesn't occur until garbage collection. Christian said these warnings are "...not a bug but a feature." Try q.drop after q.execute and see if that fixes things for you.. Ben Luis Lebron wrote: > I have a ruby script that inserts data into a SQL Server Express > database. The inserts work but I keep getting errors like the following > "WARNING: STMT 0x2954f50 was not dropped before garbage collection." > > Here's the script > ========================== > > require 'odbc' > > c=ODBC::connect('SMD') > t1 = Time.now > > aFile = File.open("C://temp/DMERECAP.SDF") > > aFile.each_line do |line| > if $. < 11 > q =c.prepare("Insert into > DMERECAP(recptlo,datepaid,invoicenum,dolapplied,payername,hcpc,servdatepd,patnum) > values ('#{line[0..6].squeeze(" ")}' ,'#{line[7..16].squeeze(" ")}', > '#{line[17..28].squeeze(" ")}', '#{line[29..40].squeeze(" ")}', > '#{line[48..87].squeeze(" ")}', '#{line[88..92].squeeze(" ")}', > '#{line[145..154].squeeze(" ")}', '#{line[138..145].squeeze(" > ").to_i}')") > q.execute() > > end > end > > puts "Import complete." > puts Time.now-t1 > > if c > c.disconnect > end > > ============ > > Any help would be appreciated. > > thanks, > > Luis > >
From: lrlebron@gmail.com on 6 Nov 2006 15:44 Thanks, That did the trick. Luis Ben Gribaudo wrote: > Hi Luis, > > I asked Christian Werner about this in the past. He told me that these > are internal warnings intended to remind the lazy programmer to > close/drop his ODBC statements. If you don't do so, their cleanup > doesn't occur until garbage collection. Christian said these warnings > are "...not a bug but a feature." > > Try q.drop after q.execute and see if that fixes things for you.. > > Ben > > Luis Lebron wrote: > > I have a ruby script that inserts data into a SQL Server Express > > database. The inserts work but I keep getting errors like the following > > "WARNING: STMT 0x2954f50 was not dropped before garbage collection." > > > > Here's the script > > ========================== > > > > require 'odbc' > > > > c=ODBC::connect('SMD') > > t1 = Time.now > > > > aFile = File.open("C://temp/DMERECAP.SDF") > > > > aFile.each_line do |line| > > if $. < 11 > > q =c.prepare("Insert into > > DMERECAP(recptlo,datepaid,invoicenum,dolapplied,payername,hcpc,servdatepd,patnum) > > values ('#{line[0..6].squeeze(" ")}' ,'#{line[7..16].squeeze(" ")}', > > '#{line[17..28].squeeze(" ")}', '#{line[29..40].squeeze(" ")}', > > '#{line[48..87].squeeze(" ")}', '#{line[88..92].squeeze(" ")}', > > '#{line[145..154].squeeze(" ")}', '#{line[138..145].squeeze(" > > ").to_i}')") > > q.execute() > > > > end > > end > > > > puts "Import complete." > > puts Time.now-t1 > > > > if c > > c.disconnect > > end > > > > ============ > > > > Any help would be appreciated. > > > > thanks, > > > > Luis > > > >
|
Pages: 1 Prev: QtRuby 1.4.7 Next: Send over raw socket? |