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 Query to execute the statement, which will return a Row object you can use to fetch results.

rows, _ := db.Query("SELECT Worker_Reference_WID, Legal_Name_Last_Name FROM [CData].[Human_Resources].Workers WHERE Legal_Name_Last_Name = 'Morgan'")
defer rows.Close()

Iterating over the Results

You can use Next to iterate through the rows in the resultset. To extract values from a row, use Scan to bind columns to local variables. The number of pointers given to Scan must match the number of columns in the resultset exactly, otherwise Scan will return an error.

for rows.Next() {
        var (
                Worker_Reference_WID string
                Legal_Name_Last_Name string
        )

        rows.Scan(&Worker_Reference_WID, &Legal_Name_Last_Name)
        fmt.Printf("Worker_Reference_WID = %s, Legal_Name_Last_Name = %s\n", Worker_Reference_WID, Legal_Name_Last_Name)
}

You may use types with Scan other than strings, as long as the data can be converted by the sql package. Please refer to the Scan function in the sql package documentation for supported types and type conversion rules.

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