I have (several) stored procedures that check for existence of a phone number in a table.
Using a regular mySQL client, the syntax is call is_wireless(aaa, eee, nnnn) where aaa is the area code, eee is the exchange and nnnn is then number.
Disclaimer: I'm strictly concerned with US telephone numbers here.
when I do a *db.Query, I get a valid return of 1 or 0 for the first record in my data file. However,
the second record dies with a [reply is not completely read] error.
Here is my function I'm calling (although I don't believe it makes a difference if my code is in a function or inline):
//should return 1 if found, 0 if not
func scrub_wireless(con *sql.DB, ac int64, exch int64, num int64) string {
var found string
fmt.Println("testing -->",ac," ",exch," ",num)
rows, err := con.Query("call is_wireless(?,?,?)",ac,exch,num)
if err != nil {
fmt.Fprintf(os.Stderr, "scrub_wireless Query failed. [%s]\r\n", err)
os.Exit(1)
}
defer rows.Close()
fmt.Println(rows.Columns())
for rows.Next() {
if err := rows.Scan(&found); err != nil {
fmt.Fprintf(os.Stderr, "scrub_wireless Query failed. [%s]\r\n", err)
os.Exit(1)
}
fmt.Printf("found is %s %t \n\r", found, found)
}
rows.Close()
return found
}
There is a fair amount of debug code in the above as I've tried to figure out what is going on.
The stored procedure returns on column, named "found" and that value is either 1 or 0 depending on
whether I have a row in the table that matches.
Also, I can set my "found" variable to be either string or int64 (and modify the return type accordingly) and
I get the same results.
I also tried *db.QueryRow (tried that first, since I only expect one row) with the same results.
I'm suspecting a bug in the driver "
github.com/ziutek/mymysql/godrv" but obviously I can't point fingers
since I'm so new at this.
Can anyone help me figure out what is going on here?
If I have to, I can just rewrite the stored procedure as a prepared statement query, but I'd rather use the
stored procedure if I can.
Thanks in advance!
Bryan