QueryRow

QueryRow execute a query which returns result in a row. It is suitable to execute queries that retrieve single record, for example select count(*) from..., select col1,col2 from table where id=?. If the query returns multiple records, only the first record will be retrieved.

  • Request QueryRowRequest
FieldTypeDesc
sqlstringsql query text
paramsarray of anyquery bind variables
  • Response QueryRowResponse
FieldTypeDesc
succesbooltrue success, false error
reasonstringresponse message
elapsestringstring to represent elapse time
valuesarray of anycolumn values of the first row

Examples

Go

Select count(*)

sqlText := `select count(*) from example`
row := cli.QueryRow(sqlText)

var count int
row.Scan(&count)

fmt.Println("count=", count)
Last updated on