Ruby ODBC SQL Server Errors

L

Luis Lebron

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
 
B

Ben Gribaudo

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
 
L

lrlebron

Thanks,

That did the trick.

Luis


Ben said:
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 said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top