[R] RMySQL and Stored procedures

Dieter Menne dieter.menne at menne-biomed.de
Tue Nov 3 10:13:43 CET 2009




Orvalho Augusto wrote:
> 
> Can someone provide me a good way to circumvent the lack of calling
> Stored Procedures from RMySQL?
> 
> I can not rewrite those stored procedures on R because there a lot
> more folks here that only understands SQL.
> 
> The stored procedure returns a resultset.
> 

Use RODBC instead.

Assuming two stored procedures : 

CREATE PROCEDURE getusers (in userid INT)
BEGIN
  SELECT name from jos_users where id > userid;
END;

CREATE PROCEDURE getusers0() 
BEGIN
  SELECT name from jos_users;
END;

The following works
#####
library(RODBC)
con = odbcConnect("mysql",uid="xxx",pwd="yyy")
users0 = sqlQuery(con,"CALL getusers0")
users0
users = sqlQuery(con,"CALL getusers(20)")
users
close(con)
#####
Dieter
-- 
View this message in context: http://old.nabble.com/RMySQL-and-Stored-procedures-tp26159085p26160033.html
Sent from the R help mailing list archive at Nabble.com.




More information about the R-help mailing list