I am trying to execute a query or the form:
SELECT a.col1, b.col2 FROM tbl1 a, tbl2 b
WHERE a.col2 = b.col1
AND a.col3 = df$x
AND a.col4 = df$y
On an Oracle database using RJDBC. I have a data frame with columns x and y which identify. I can't find any details on how to generate and execute the query for the individual values in my data frame.
My data frame is of the form:
df <- data.frame(x=c("LIB258", "LIB258", "LIB359"), y=c("A01", "B03", "C08"))
So I need a way to generate and sequentially run the three different queries, then collect the results into a data frame.
Is there an elegant way to do this in R? I know I can use a bit of paste
magic to build the individual queries, but then how do I run them and return the results to a dataframe?
Thanks Hassan