tags:

views:

40

answers:

0

When using ROracle in R, I want to bind some parameters to data, so I do this:

> dbh <- dbConnect('Oracle', 'user/[email protected]:port/sid')
> st <- dbPrepareStatement(dbh, statement="SELECT x FROM mytab WHERE id=:1",
                           bind="character")
> st <- dbExecStatement(st, data.frame(id=c("9ae", "1f3"), stringsAsFactors=F))
> fetch(st)
    x
0 FOO

What's unexpected is that it only uses the first row of the data frame to do the SELECT (if it were using both rows, I'd get 2 output rows in this case, not 1), contrary to the ROracle documentation:

The object that dbPrepareStatement produces is then used together with a data.frame (which should agree with the bound specification) in calls to dbExecStatement to be executed for each row of the data.frame.

Am I doing this wrong, or does the above verbiage perhaps only apply to INSERT/UPDATE statements?