Parameterized Statements
The following code example shows how to bind parameters to create parameterized statements.
Single-Use Statements
The sqlExecute function from RODBCext accepts an additional data frame for binding query parameters to values.
sqlExecute( cnx, query = "SELECT InvoiceId, InvoiceNumber FROM INVOICES WHERE CustomerName = ?", data = data.frame("NewTech Industries") ) results <- sqlGetResults(cnx, max = 1000) while (is.data.frame(results)) { for (row in 1:nrow(results)) { cat(paste("InvoiceId = ", results[row,]$InvoiceId, "\n")) cat(paste("InvoiceNumber = ", results[row,]$InvoiceNumber, "\n")) } results <- sqlGetResults(cnx, max = 1000) }