Skip to content

RpgSQL row names

3 messages · Ben quant, Gabor Grothendieck

#
On Mon, Nov 7, 2011 at 5:34 PM, Ben quant <ccquant at gmail.com> wrote:
The RJDBC based drivers currently don't support that. You can create a
higher level function that does it.

dbGetQuery2 <- function(...) {
  out <- dbGetQuery(...)
  i <- match("row_names", names(out), nomatch = 0)
  if (i > 0) {
    rownames(out) <- out[[i]]
    out <- out[-1]
  }
  out
}

rownames(BOD) <- letters[1:nrow(BOD)]
dbWriteTable(con, "BOD", cbind(row_names = rownames(BOD), BOD))
dbGetQuery2(con, "select * from BOD")