ODBC Driver for Oracle Eloqua Reporting

Build 25.0.9434

Parameterized Statements

The following code example shows how to bind parameters to create parameterized statements.

Single-Use Statements

The Query and Exec functions both accept additional parameters for binding query parameters to values.

rows, _ := db.Query("SELECT accountId, accountName FROM AccountActivity.Account WHERE accountId = ?", "1")
defer rows.Close()
for rows.Next() {
        var (
                accountId string
                accountName string
        )

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

Reusable Statements

The Prepare function creates prepared Stmt objects, which can be re-used across multiple Query and Exec calls.

stmt, _ := db.Prepare("SELECT accountId, accountName FROM AccountActivity.Account WHERE accountId = ?")
defer stmt.Close()

rows, _ := stmt.Query("1 1")
defer rows.Close()
for rows.Next() {
        var (
                accountId string
                accountName string
        )

        rows1.Scan(&accountId, &accountName)
        fmt.Printf("accountId = %s, accountName = %s\n", accountId, accountName)
}

rows, _ = stmt.Query("1 2")
defer rows.Close()
for rows.Next() {
        var (
                accountId string
                accountName string
        )

        rows2.Scan(&accountId, &accountName)
        fmt.Printf("accountId = %s, accountName = %s\n", accountId, accountName)
}

Copyright (c) 2025 CData Software, Inc. - All rights reserved.
Build 25.0.9434