oph is a hack to use out parameters in MySQL stored procedures with Go sql drivers.
db, err := sql.Open("mymysql", "DBNAME/USER/PASSWD")
if err != nil {
panic(err)
}
defer db.Close()
// CALL EXAMPLE('example',1,NULL,@outString)
var outString sql.NullString
if err := oph.Call(db, func(resultSetIndex int, rows *sql.Rows) error {
for rows.Next() {
var id int64
var name sql.NullString
rows.Scan(&id, &name)
}
return rows.Err()
}, "EXAMPLE", "example", 1, nil, &outString); err != nil {
panic(err)
}