1) Create a class and let’s call it
Class CallStoredProcedures
your methods here …….
end
2) Create a class method within it
def self.fetch_db_records(proc_name_with_parameters)
ActiveRecord::Base.connection.execute(proc_name_with_parameters)
end
Then simply call it as
CallStoredProcedures.fetch_db_records(“exec procedure_name ‘args1′, ‘args2′, ‘and so on’ “)
Now you might say, that this will only execute a procedure what if I want to return records or values from stored procedures. Then I will [...]
Archive for September 16th, 2008
Stored Procedures in Ruby on Rails
Posted in Ruby on Rails (RoR) on September 16, 2008 | Leave a Comment »