CData ODBC Driver for Amazon Marketplace 2019 - Online Help
Questions / Feedback?

Querying Data

CData ODBC Driver for Amazon Marketplace 2019 - Build 19.0.7354

After Connecting, you can execute a SQL statement and retrieve the results.

SELECT Procedure

You can use the sqlQuery function to execute queries. By default, it will return all the results as a single data frame. This works well for smaller result sets.

results <- sqlQuery(cnx, "SELECT Id, Column1 FROM SampleTable_1 WHERE Column2 = 'Bob'")
for (row in 1:nrow(results)) {
    cat(paste("Id = ", results[row,]$Id, "\n"))
    cat(paste("Column1 = ", results[row,]$Column1, "\n"))
}

Iterating over the Results

For larger result sets, sqlQuery can return results in batches instead of storing the entire result set in memory. When there are no results left, or an error occurs, sqlQuery and sqlGetResults will return an integer error code instead of a data frame.

results <- sqlQuery(cnx, "SELECT Id, Column1 FROM SampleTable_1 WHERE Column2 = 'Bob'", max = 1000)
while (is.data.frame(results)) {
    for (row in 1:nrow(results)) {
        cat(paste("Id = ", results[row,]$Id))
        cat(paste("Column1 = ", results[row,]$Column1))
    }
    rows <- sqlGetResults(cnx, max = 1000)
}

 
 
Copyright (c) 2020 CData Software, Inc. - All rights reserved.
Build 19.0.7354.0