Go processing result set
After executing a query, a response returns rows that match the SELECT statement.
You can call getResultSet()
on the response to grab a ResultSet
to process.
Note the function may return undefined
if no ResultSet
is returned; check if it is defined or cast.
result := response.GetResultSet()
var i, j int
for i = 0; i < 2; i++ {
valueToPrint := ""
for j = 0; j < 2; j++ {
value, err := client.ToString(result.Rows[i].Values[j])
if err != nil {
fmt.Printf("error getting value %v", err)
os.Exit(1)
}
valueToPrint += " "
valueToPrint += value
}
fmt.Printf("%v \n", valueToPrint)
}
}
Since the result type is known, the ToString
function transforms the value into a native string.
Additional functions also exist for other types such as int
, map
, and blob
.
The full list can be found in
values.go.