[R-sig-DB] Opening multiple result sets
Paul Dlug
p@u|@d|ug @end|ng |rom gm@||@com
Sun Jul 15 22:42:34 CEST 2007
I'm rather new to using R DBI so please excuse me if this is beyond
basic. I don't seem to be able to open more than one resultset at
time, I'm trying the following:
drv <- dbDriver("MySQL")
con <- dbConnect(drv, ...)
rs1 <- dbSendQuery(con, "SELECT ...")
while (!dbHasCompleted(rs1)) {
data1 <- fetch(rs1, n=1)
rs2 <- dbSendQuery(con, past("SELECT ... WHERE id =", data1$id))
data2 <- fetch(rs2, n=1)
dbClearResult(rs2)
}
dbClearResult(rs1)
dbDisconnect(con)
When I try to execute it I get the error:
Error in mysqlExecStatement(conn, statement, ...) :
RS-DBI driver: (connection with pending rows, close resultSet before
continuing)
What I'm trying to accomplish is operating on the results of the first
query one row at a time and using the returned values to perform
another query and analyze the results. The first query is going to
return a large amount of data so I don't really want to fetch all rows
into memory up front, close the result set and proceed.
Any help/suggestions would be greatly appreciated.
Thanks,
Paul
More information about the R-sig-DB
mailing list