Closed dmzkrsk closed 12 months ago
I try to use sqlexp.Messages as it's implemented in https://github.com/denisenkom/go-mssqldb/pull/690
sqlexp.Messages
I created a test procedure and run it in docker image mcr.microsoft.com/azure-sql-edge:latest
mcr.microsoft.com/azure-sql-edge:latest
CREATE OR ALTER PROCEDURE procedureWithPrint AS BEGIN PRINT N'1'; PRINT N'2'; SELECT * from example WHERE id > 7 ORDER BY ID desc; PRINT N'3'; END;
Using an example code in https://github.com/microsoft/go-mssqldb/blob/main/messages_example_test.go#L69 I get only two first prints, since after the SELECT, NextResultSet returns false
SELECT
NextResultSet
false
If I remove active = rows.NextResultSet() (so active is always true) I get message with 3, but the loop does not break.
active = rows.NextResultSet()
active
true
3
When procedure contains no selects:
CREATE OR ALTER PROCEDURE procedureWithPrint AS BEGIN PRINT N'1'; PRINT N'2'; PRINT N'3'; END;
I get all three messages
Am I doing it wrong? What is correct way to get all three messages AND select results AND make the loop to stop?
I try to use
sqlexp.Messages
as it's implemented in https://github.com/denisenkom/go-mssqldb/pull/690I created a test procedure and run it in docker image
mcr.microsoft.com/azure-sql-edge:latest
Using an example code in https://github.com/microsoft/go-mssqldb/blob/main/messages_example_test.go#L69 I get only two first prints, since after the
SELECT
,NextResultSet
returnsfalse
If I remove
active = rows.NextResultSet()
(soactive
is alwaystrue
) I get message with3
, but the loop does not break.When procedure contains no selects:
I get all three messages
Am I doing it wrong? What is correct way to get all three messages AND select results AND make the loop to stop?