Return <nil> from sqlite DB, give scan error


if a column in to sqlite-database NULL become <nil> back and this is a wrong type string

var name string
var tel string
var ort string

err = dbo.QueryRow("SELECT name, tel, ort FROM organisation WHERE oid=?", GetSessionValueInt(r, "oid")).Scan(&name, &tel, &ort)
if err != nil {

The error-output:

sql: Scan error on column index 2: unsupported Scan, storing driver.Value type <nil> into type *string

What is the right handle with column-type string or int when the result is <nil>?

Use the sql.NullSomething types. Here’s the first Google result on it, with a nice article: :wink:

1 Like

Thx, I’ll read it later. I solve it:

 COALESCE(tel, '') as tel

is not elegant, but … :wink:

I tried just now


I had no success

Thanks again!

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.