lundi 23 mars 2015

parse error when running oracle stored procedure through rails

I am running to run an oracle stored procedure in rails, but I am getting the following error:



ActionView::Template::Error (undefined method `parse' for
#<Mysql2::Client:0x00000008ef4310>):


in the following line:



cursor = connection.parse(sql)


This is my database.yml file



development:
adapter: mysql2
database: db1
username: user1
password: *****
host: *****
port: 3306

db1_development:
adapter: mysql2
username: user2
password: ****
database: ****
host: *****
port: 3306

db2_development:
adapter: mysql2
database: user3
username: ******
password: ******
host: *****
port: 3309

db3_development:
adapter: oracle_enhanced
database: user3
username: *****
password: *****


these are my 2 model classes:



module Sts

class StsLtd < Sts::Base
def number
errormsg = nil
errorcode = nil
sperrormsg = nil
vpan = nil

sql =
"BEGIN #{Pkgltd::PKG_LTD}.GET_PAN('
8042049440330819','32', 'TEST', '0',vpan, errormsg, errorcode, sperrormsg);
END;"

connection = self.connection.raw_connection
cursor = connection.parse(sql)

cursor.bind_param(:errormsg, nil, String, 1000)
cursor.bind_param(:errorcode, nil, String, 1000)
cursor.bind_param(:sperrormsg, nil, String, 1000
cursor.bind_param(:vpan, nil, String, 1000)

cursor.exec

vpan, errormsg, errorcode, sperrormsg, vpan = cursor[:vpan], cursor[:errormsg], cursor[:errorcode], cursor[:sperrormsg]
cursor.close
vpan
end
end
end


sts.rb:



module Sts

PKG_LTD ="PKG_LTD"

class Base < ActiveRecord::Base
self.abstract_class = true
establish_connection = "db3_#{Rails.env}"

end
end


I am not sure why it is throwing mysql parse error, when the specific set of code is only trying to connect to the oracle database and running the oracle stored procedure.


Aucun commentaire:

Enregistrer un commentaire