Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

can not get query error #737

Closed
kinwyb opened this issue Apr 28, 2022 · 1 comment
Closed

can not get query error #737

kinwyb opened this issue Apr 28, 2022 · 1 comment

Comments

@kinwyb
Copy link

kinwyb commented Apr 28, 2022

Describe the bug
can not get error for result but log show error msg

Stack trace:
2022/04/28 15:06:48 got token tokenLoginAck
2022/04/28 15:06:48 got token tokenEnvChange
2022/04/28 15:06:48 got token tokenDone
2022/04/28 15:06:48 got DONE or DONEPROC status=0
2022/04/28 15:06:48 got token tokenColMetadata
2022/04/28 15:06:48 got token tokenRow
2022/04/28 15:06:48 got token tokenDone
2022/04/28 15:06:48 got DONE or DONEPROC status=16
2022/04/28 15:06:48 got token tokenEnvChange
2022/04/28 15:06:48 got token tokenEnvChange
2022/04/28 15:06:48 got token tokenDone
2022/04/28 15:06:48 got DONE or DONEPROC status=0
2022/04/28 15:06:48 got token tokenColMetadata
2022/04/28 15:06:48 got token tokenError
2022/04/28 15:06:48 got ERROR 8169 将字符串转换为 uniqueidentifier 时失败。
2022/04/28 15:06:48 got token tokenEnvChange
2022/04/28 15:06:48 got token tokenDone
2022/04/28 15:06:48 got DONE or DONEPROC status=2
2022/04/28 15:06:48 got token tokenDoneInProc
2022/04/28 15:06:48 got token tokenReturnStatus
2022/04/28 15:06:48 got token tokenDoneProc
2022/04/28 15:06:48 got DONE or DONEPROC status=0
2022/04/28 15:06:48 got token tokenError
2022/04/28 15:06:48 got ERROR 3902 COMMIT TRANSACTION 请求没有对应的 BEGIN TRANSACTION。
2022/04/28 15:06:48 got token tokenDone
2022/04/28 15:06:48 got DONE or DONEPROC status=2
    mssql_test.go:133: mssql: COMMIT TRANSACTION 请求没有对应的 BEGIN TRANSACTION。

To Reproduce

db, _ := conn.GetDb()
tx, err := db.BeginTx(context.Background(), nil)
if err != nil {
return
}
sql := "SELECT * FROM [DispatchMaster] WHERE DispatchMasterID = ''"
_,err = tx.Query(sql)
if err != nil {
tx.Rollback()
return
}
sql = "INSERT INTO MACHINES_STATE (state,display,[desc]) VALUES (?,?,?)"
_,err = tx.Exec(sql,4,"test","test")
if err != nil {
return
}
err = tx.Commit()
if err != nil {
return
}

Expected behavior

output "ERROR 8169 将字符串转换为 uniqueidentifier 时失败" I want query result can get error

Further technical details

SQL Server version: 2016, 2019
Operating system: windows 2016

CREATE Table DispatchMaster (
DispatchMasterID uniqueidentifier
)

@kinwyb
Copy link
Author

kinwyb commented Apr 29, 2022

I can get the error after reading the result, but the transaction has been rolled back. Can I judge whether the transaction has been rolled back and do not do commit event.

@kinwyb kinwyb closed this as completed May 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant