パラメータ化されたステートメント
次のコード例は、パラメータをバインドしてパラメータ化されたステートメントを作成する方法を示します。
シングルユース ステートメント
RODBCext のsqlExecute 関数は、クエリパラメータを値にバインドするための追加のデータフレームを受け入れます。
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)
}