execute_procedure using named parameters?

148 views
Skip to first unread message

Krzysztof Chodak

unread,
Mar 1, 2012, 7:21:26 AM3/1/12
to rails-sqlse...@googlegroups.com
Hi all, is it possible to execute procedure using named parameters or passing parameters in correct order is the only way?

Justin Tifang

unread,
Mar 2, 2012, 3:31:00 PM3/2/12
to rails-sqlse...@googlegroups.com
Hi Krzysztof,

It seems as if you can't do that. Look at this code:

----------------
def execute_procedure(proc_name, *variables)
vars = variables.map{ |v| quote(v) }.join(', ')
sql = "EXEC #{proc_name} #{vars}".strip
name = 'Execute Procedure'
...
-----------------

It seems parameters  are split, 'special characters' escaped and passed to the SP.

I guess it'll be possible to create another function to pass named parameters, but that means the stored procedure creator has to have set defaults as otherwise the stored proc will throw an error for missing parameters that do no have defaults set.

I've just discovered Ruby and it seems a fantastic language and I'm just starting to investigate DB functionalities ... currently looking at tinyTDS

Justin


Date: Thu, 1 Mar 2012 04:21:26 -0800
From: krzyszto...@gmail.com
To: rails-sqlse...@googlegroups.com
Subject: [RailsSQLServer] execute_procedure using named parameters?


Hi all, is it possible to execute procedure using named parameters or passing parameters in correct order is the only way?
--
You received this message because you are subscribed to the Google Groups "Rails SQLServer Adapter" group.
To view this discussion on the web visit https://groups.google.com/d/msg/rails-sqlserver-adapter/-/XTbX3yrLxZAJ.
To post to this group, send email to rails-sqlse...@googlegroups.com.
To unsubscribe from this group, send email to rails-sqlserver-a...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rails-sqlserver-adapter?hl=en.
Reply all
Reply to author
Forward
0 new messages