Hi,
First, I’d like to thank you all for the help you’ve provided me in the past, despite this being my first post here.
Now, my problem. I’m having some trouble with basic DBI functionality. In its simplist form, my script:
#!c:\ruby\bin\ruby.exe -w
require ‘DBI’
begin
dbh=DBI.connect(“dbi:Oracle:db”,“user”,“password”)
sth=dbh.prepare(“insert into test_and_drop (id, descript) values (?,?)”)
dbh.execute(“1”,“Because”)
rescue DBI::DatabaseError => e
puts "An error occurred"
print "Error Code: ", e.err, "\n"
print "Error Message: ", e.errstr, "\n"
ensure
dbh.disconnect if dbh
end
This is almost directly out of “Using the DBI Module” by Paul DuBios*, so I would think that it would work, but, on the prepare, I’m getting:
C:/ruby/lib/ruby/site_ruby/1.6/DBD/Oracle/Oracle.rb:34: warning: discarding old to_i
An error occurred
Error Code: 1003
Error Message: ORA-01003: no statement parsed
I’m running ruby 1.6.7 on Win2K, connecting to an Oracle 8i db. Anybody know what might be happening here? My hair is getting thinner by the minute…
Thank you,
Marty
*Credit where credit is due…
Hi,
As it turns out, my problems run much deeper than this. I simplified the problem a little too much, and goofed because of it. I’m very sorry to have wasted your time.
Marty.
···
----- Original Message -----
From: Martin Bonner
To: ruby-talk ML
Sent: Friday, February 14, 2003 1:11 PM
Subject: DBI, oracle, and prepare
Hi,
First, I’d like to thank you all for the help you’ve provided me in the past, despite this being my first post here.
Now, my problem. I’m having some trouble with basic DBI functionality. In its simplist form, my script:
#!c:\ruby\bin\ruby.exe -w
require ‘DBI’
begin
dbh=DBI.connect(“dbi:Oracle:db”,“user”,“password”)
sth=dbh.prepare(“insert into test_and_drop (id, descript) values (?,?)”)
dbh.execute(“1”,“Because”)
rescue DBI::DatabaseError => e
puts "An error occurred"
print "Error Code: ", e.err, "\n"
print "Error Message: ", e.errstr, "\n"
ensure
dbh.disconnect if dbh
end
This is almost directly out of “Using the DBI Module” by Paul DuBios*, so I would think that it would work, but, on the prepare, I’m getting:
C:/ruby/lib/ruby/site_ruby/1.6/DBD/Oracle/Oracle.rb:34: warning: discarding old to_i
An error occurred
Error Code: 1003
Error Message: ORA-01003: no statement parsed
I’m running ruby 1.6.7 on Win2K, connecting to an Oracle 8i db. Anybody know what might be happening here? My hair is getting thinner by the minute…
Thank you,
Marty
*Credit where credit is due…
Martin Bonner wrote:
#!c:\ruby\bin\ruby.exe -w
require ‘DBI’
Hmm…does Windows ignore case for module names? Guess so.
Error Message: ORA-01003: no statement parsed
This almost always means there was a problem parsing the SQL itself,
although looking at your code nothing obvious stands out.
Try wrapping the prepare and execute separately with begin/rescue to see
where the problem is (likely the prepare). Be sure to test the same sql
on the command line (or TOAD or whatever) to make sure the sql is truly
valid.
HTH
Regards,
Dan
···
–
a = [74, 117, 115, 116, 32, 65, 110, 111, 116, 104, 101, 114, 32, 82]
a.push(117,98, 121, 32, 72, 97, 99, 107, 101, 114)
puts a.pack(“C*”)