ODBC Driver for Teradata

Build 23.0.8839

パラメータ化されたステートメント

次のコード例は、パラメータをバインドしてパラメータ化されたステートメントを作成する方法を示します。

シングルユース ステートメント

RODBCext のsqlExecute 関数は、クエリパラメータを値にバインドするための追加のデータフレームを受け入れます。

sqlExecute(
    cnx,
    query = "SELECT ProductId, ProductName FROM \"CData\".\"dbo\".NorthwindProducts WHERE CategoryId = ?",
    data = data.frame("5")
)

results <- sqlGetResults(cnx, max = 1000)
while (is.data.frame(results)) {
    for (row in 1:nrow(results)) {
        cat(paste("ProductId = ", results[row,]$ProductId, "\n"))
        cat(paste("ProductName = ", results[row,]$ProductName, "\n"))
    }
    results <- sqlGetResults(cnx, max = 1000)
}

Copyright (c) 2024 CData Software, Inc. - All rights reserved.
Build 23.0.8839