Try this:
# I'd avoid new as a variable name
newdata <- sqlQuery(newconn,"SELECT COL1, COL2 FROM TABLE1;", errors = TRUE, 1)
# index data frame by row number and column name
if (newdata[3, "COL1"] == "someValue") {
print("found someValue")
} else {
print ("failed")
}
You can also do
if (newdata[3, 2] == "MYSTRING")
to index by row and column index.
Lastly, testing for NA is different than string comparison -- you need is.null()
or is.na()
as this may get converted by the ODBC access.
Dirk Eddelbuettel
2009-12-29 11:24:57