Can't execute stored procedure in ruby

I have written ruby code to connect SQL server , using gem ‘odbc’ i
could connect sql server and execute query to select and update tables
but when i tried to call stored procedure it skips the execution and
shows no error
here is my code

require ‘rubygems’
require ‘odbc’
odbcdatasource = ‘odbcdata’
usrname = ‘uname’
pswd = ‘paswd’

sqlQuery = “EXEC create_candidates”
ODBC.connect(odbcdatasource,usrname,pswd)do |bd|
results = bd.run(sqlQuery)

Is there any other method to call stored procedure in ruby code ??

thank you
nibin c

Hi nibin,

my advice is to use something like activerecord
(https://rubygems.org/gems/activerecord/versions/4.2.6) because in the
long run, it’s going to make your life a lot easier.

Otherwise, there seems to be quite a bit of information about ruby-odbc
collected in this forum, if you use the search box you can search
through the answers to similar problems.

In the example you posted, you haven’t closed the block with “end”. It’s
also helpful to take the extra couple of minutes to format the code so
that it’s easier for everyone to read.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs