Hey guys, I’m trying to get result from a SQL Server stored procedure but I always get the following error;
In my case it’s SQL Server, but I’m reading here many other people complainments with other databases too, such as MySQL and Oracle, people getting the same issue… Searching a bit more I saw that it’s a GO limitation. How can I handle on this? My procedure returns for example;
SELECT -1 AS RESULT
Or other values, depending on what happens inside the procedure, and always with the alias RESULT… Below is my try;
var ret int
sqlstr2 := "EXEC PRCENVIACOMANDO @IDVEICULO=" + urlqry.Get("idveiculo") + ", @CMD=2"
err2:= db.QueryRow(sqlstr2).Scan(&ret)
if err2 != nil {
GeraLog(err2.Error())
return
}
My procedure executes, but I can’t get the result.
I’m not sure if it’s contributing to the problem you are having but I will suggest using placeholder parameters in the QueryRow function instead of a self formatted string.
Something else I would like to mention is to look at using Named parameters(go1.8) and Out(go1.9) when working with stored procedures. The Go mssql driver have support for these.
Hey there, I resolved my problem by adding “set nocount on;” before my procedure call, I never needed to do it with no other language, but that did the trick. If any one needs this someday, that’s how I resolved.