stored procedures and ROR

dear friends,

I need to execute mysql stored procedure with input parameter and need to get some values to ROR calling application.

if some one have idea please let me know.

thanks

sam

Hey Sam, You can use execute function of Activerecord and call the store procedure. active_record_object = YourActiveRecord.new stmt = active_record_object.connection.execute(sql_call_to_stored_procedure) # object of array to store the result records = while row = MySQL::fetch_array(stmt) records << row end

Hope this may help :slight_smile: .

Regards, Naren

i think i used same way. but it was not success. please check.

============== proc. ======================

DELIMITER $$

CREATE DEFINER=root@localhost PROCEDURE proc_validate_login(IN param_uname varchar(50),IN param_pwd varchar(50),OUT test varchar(50))

BEGIN

DECLARE res int;

Select username into test from tbl_users where

‘userName’ = param_uname and ‘PWD’ = param_PWD;

#insert into tbl_users(userName,pwd) values(test,‘sampath2’);

END

why don’t you use select query or ActiveRecord.find for fetching a record from table? I guess its better way.

Regards, Narendra

I need to get status of insertions and need to create new userID inside the stored proc. thats why I need to use this.

s/need/want/

Nothing there you can't do *without* resorting to SPs.

Michael Pavling wrote:

this time i’m doing little bit large project. main concerns are security and performance. thats why im looking for the stored procs. I really really need this.

Sampath Munasinghe wrote:

this time i'm doing little bit large project. main concerns are security

Which stored procedures will not help with.

and performance.

Which stored procedures may or may not help with.

thats why im looking for the stored procs. I really really need this.

No, you probably don't.

what do u mean ?

Sampath Munasinghe wrote:

what do u mean ?

By what? Since you failed to quote the text you were replying to, I have no idea what you're referring to.

On Wed, Jun 23, 2010 at 12:35 AM, Marnen Laibow-Koser

Best,

Sampath, Five minutes of googling turned up a ton of references. Check out the following:

There were many more. Type in

using stored procedures in Ruby on Rails and you will get a lot of references.

Bharat