ODBC Driver for Workday

Build 23.0.8839

Querying Data

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 Worker_Reference_WID, Legal_Name_Last_Name FROM [CData].[Human_Resources].Workers WHERE Legal_Name_Last_Name = 'Morgan'")
for (row in 1:nrow(results)) {
    cat(paste("Worker_Reference_WID = ", results[row,]$Worker_Reference_WID, "\n"))
    cat(paste("Legal_Name_Last_Name = ", results[row,]$Legal_Name_Last_Name, "\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 Worker_Reference_WID, Legal_Name_Last_Name FROM [CData].[Human_Resources].Workers WHERE Legal_Name_Last_Name = 'Morgan'", max = 1000)
while (is.data.frame(results)) {
    for (row in 1:nrow(results)) {
        cat(paste("Worker_Reference_WID = ", results[row,]$Worker_Reference_WID))
        cat(paste("Legal_Name_Last_Name = ", results[row,]$Legal_Name_Last_Name))
    }
    rows <- sqlGetResults(cnx, max = 1000)
}

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