I am trying to fetch data using RMySQL fetch method with n=100 in this loop:

lquery = paste(query," limit 10")
input = dbGetQuery(con1,lquery)
res = dbSendQuery(con1,query)
completed = FALSE
count = 0
while (completed != TRUE) {
  count = count + 1
  batch = fetch(res, n = 100)
  print (paste("batch",count))
  input = merge(input,batch,all=TRUE)
  print (paste("merge",count))
  completed = dbHasCompleted(res)
}

But after a while, I get this error:

...
[1] "batch 211"
[1] "merge 211"
[1] "batch 212"
Error in rep.int(rep.int(seq_len(nx), rep.int(rep.fac, nx)), orep) :
  invalid 'times' value
In addition: Warning messages:
1: In mysqlFetch(res, n, ...) :
  RS-DBI driver warning: (error while fetching rows)
2: In mysqlFetch(res, n, ...) :
  RS-DBI driver warning: (error while fetching rows)
>

What could be causing this? Is there any other way to do this?

	[[alternative HTML version deleted]]


