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 -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
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 :) . Regards, Naren On Mon, Jun 21, 2010 at 2:36 PM, Sampath Munasinghe <sampathnisha-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>wrote:> 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 > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > . > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. >-- ~N a r e n -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
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 =========================================== i''m trying to call proc using this command ActiveRecord::Base.connection.execute("call proc_validate_login(''sam'',''sam'',@test)") for insertion this is working. but i need to execute select statement and getting some values from proc. do u have idea? On Mon, Jun 21, 2010 at 9:18 PM, Narendra sisodiya <naren.sisodiya-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> 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 :) . > > Regards, > Naren > > > > > On Mon, Jun 21, 2010 at 2:36 PM, Sampath Munasinghe < > sampathnisha-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > >> 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 >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Ruby on Rails: Talk" group. >> To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> To unsubscribe from this group, send email to >> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> >> . >> For more options, visit this group at >> http://groups.google.com/group/rubyonrails-talk?hl=en. >> > > > > -- > ~N a r e n > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > . > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
why don''t you use select query or ActiveRecord.find for fetching a record from table? I guess its better way. Regards, Narendra On Mon, Jun 21, 2010 at 8:47 PM, Sampath Munasinghe <sampathnisha-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>wrote:> 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 > > ===========================================> > i''m trying to call proc using this command > > > ActiveRecord::Base.connection.execute("call proc_validate_login(''sam'',''sam'',@test)") > > > for insertion this is working. but i need to execute select statement and > getting some values from proc. > > do u have idea? > > > > > > > > > > > > > > > On Mon, Jun 21, 2010 at 9:18 PM, Narendra sisodiya < > naren.sisodiya-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > >> 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 :) . >> >> Regards, >> Naren >> >> >> >> >> On Mon, Jun 21, 2010 at 2:36 PM, Sampath Munasinghe < >> sampathnisha-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> >>> 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 >>> >>> -- >>> You received this message because you are subscribed to the Google Groups >>> "Ruby on Rails: Talk" group. >>> To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>> To unsubscribe from this group, send email to >>> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> >>> . >>> For more options, visit this group at >>> http://groups.google.com/group/rubyonrails-talk?hl=en. >>> >> >> >> >> -- >> ~N a r e n >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Ruby on Rails: Talk" group. >> To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> To unsubscribe from this group, send email to >> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> >> . >> For more options, visit this group at >> http://groups.google.com/group/rubyonrails-talk?hl=en. >> > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > . > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. >-- ~N a r e n -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
I need to get status of insertions and need to create new userID inside the stored proc. thats why I need to use this. On Tue, Jun 22, 2010 at 12:59 PM, Narendra sisodiya < naren.sisodiya-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > why don''t you use select query or ActiveRecord.find for fetching a record > from table? I guess its better way. > > Regards, > Narendra > > > > > On Mon, Jun 21, 2010 at 8:47 PM, Sampath Munasinghe < > sampathnisha-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > >> 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 >> >> ===========================================>> >> i''m trying to call proc using this command >> >> >> ActiveRecord::Base.connection.execute("call proc_validate_login(''sam'',''sam'',@test)") >> >> >> for insertion this is working. but i need to execute select statement and >> getting some values from proc. >> >> do u have idea? >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> On Mon, Jun 21, 2010 at 9:18 PM, Narendra sisodiya < >> naren.sisodiya-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> >>> 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 :) . >>> >>> Regards, >>> Naren >>> >>> >>> >>> >>> On Mon, Jun 21, 2010 at 2:36 PM, Sampath Munasinghe < >>> sampathnisha-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>> >>>> 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 >>>> >>>> -- >>>> You received this message because you are subscribed to the Google >>>> Groups "Ruby on Rails: Talk" group. >>>> To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>> To unsubscribe from this group, send email to >>>> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> >>>> . >>>> For more options, visit this group at >>>> http://groups.google.com/group/rubyonrails-talk?hl=en. >>>> >>> >>> >>> >>> -- >>> ~N a r e n >>> >>> -- >>> You received this message because you are subscribed to the Google Groups >>> "Ruby on Rails: Talk" group. >>> To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>> To unsubscribe from this group, send email to >>> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> >>> . >>> For more options, visit this group at >>> http://groups.google.com/group/rubyonrails-talk?hl=en. >>> >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Ruby on Rails: Talk" group. >> To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> To unsubscribe from this group, send email to >> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> >> . >> For more options, visit this group at >> http://groups.google.com/group/rubyonrails-talk?hl=en. >> > > > > -- > ~N a r e n > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > . > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 22 June 2010 07:57, Sampath Munasinghe <sampathnisha-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> 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. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Michael Pavling wrote:> On 22 June 2010 07:57, Sampath Munasinghe <sampathnisha-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > wrote: >> 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.Correct. But if a SP really is the best solution in this case (there are a few such situations!), perhaps you can use find_by_sql or something to retrieve records. Best, -- Marnen Laibow-Koser http://www.marnen.org marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
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. On Tue, Jun 22, 2010 at 9:01 PM, Marnen Laibow-Koser <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org>wrote:> Michael Pavling wrote: > > On 22 June 2010 07:57, Sampath Munasinghe <sampathnisha-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > > wrote: > >> 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. > > Correct. But if a SP really is the best solution in this case (there > are a few such situations!), perhaps you can use find_by_sql or > something to retrieve records. > > Best, > -- > Marnen Laibow-Koser > http://www.marnen.org > marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org > -- > Posted via http://www.ruby-forum.com/. > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > . > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Sampath Munasinghe wrote:> this time i''m doing little bit large project. main concerns are > securityWhich 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.> > > > > On Tue, Jun 22, 2010 at 9:01 PM, Marnen Laibow-Koser-- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
what do u mean ? On Wed, Jun 23, 2010 at 12:35 AM, Marnen Laibow-Koser <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org>wrote:> 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. > > > > > > > > > > > > On Tue, Jun 22, 2010 at 9:01 PM, Marnen Laibow-Koser > > -- > Posted via http://www.ruby-forum.com/. > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > . > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
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-KoserBest, -- Marnen Laibow-Koser http://www.marnen.org marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Sampath, Five minutes of googling turned up a ton of references. Check out the following: http://nasir.wordpress.com/2007/12/03/stored-procedures-and-rails/ http://guyharrison.typepad.com/guy_harrisons_blog/2006/04/mysql_stored_pr.html http://paslogic.com/?p=13 There were many more. Type in using stored procedures in Ruby on Rails and you will get a lot of references. Bharat -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.