Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > ruby-odbc and OUTPUT params not working

Thread Tools

ruby-odbc and OUTPUT params not working

Chris Hall
Posts: n/a
connecting to an SQLExpress database to run a stored procedure, and
output parameters are not working. If anyone has any help they can
give, it would be greatly appreciated.

require 'rubygems'
require 'odbc'

# CREATE PROCEDURE dbo.up_TestSP4(@NotUsed INT, @ReturnVar INT OUTPUT)
# AS
# SET @ReturnVar = 666
# /*
# EXEC dbo.up_TestSP4 10, @P2 OUTPUT
# */

# Error:
# 2000 (8162) [FreeTDS][SQL Server]The formal parameter "@P2" was not
# declared as an OUTPUT parameter, but the actual parameter passed in
# requested output.
# odbc_test.rb:26:in `execute'

conn = ODBC:atabase.connect("dsn", "xxx", "xxx")
stmt = conn.prepare("exec dbo.up_TestSP4 ?, ?")
stmt.param_iotype(1, ODBC::SQL_PARAM_OUTPUT)
stmt.param_output_type(1, ODBC::SQL_INTEGER)
stmt.param_output_size(1, 4)
res = stmt.execute(1, nil)
out_value = stmt.param_output_value(1)
puts "#{out_value}"
rescue Exception => e
puts e
puts e.backtrace.join("\n")
stmt.cancel if stmt
conn.disconnect if conn && conn.connected?
Posted via

Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
ODBC: Obtaining output params Ruby 0 12-20-2006 11:58 PM
ods calls business object then method calls ta with output params andy6 ASP .Net 2 06-09-2006 01:54 AM
Calling DLL with several data fields in output params Java script Dude Python 2 01-29-2006 03:50 AM
params v.s. @params in rails? Barry Ruby 9 09-15-2005 03:12 AM
Seeking Example of sqlHelper w/output params JDP@Work ASP .Net Web Controls 0 01-14-2005 11:42 PM