database/sql: add error check

Signed-off-by: guoguangwu <guoguangwu@magic-shield.com>
This commit is contained in:
guoguangwu 2024-02-26 17:24:55 +08:00
parent 7db8b9e518
commit afbb86fde1
1 changed files with 4 additions and 0 deletions

View File

@ -140,6 +140,10 @@ where
var orderRef = "ABC123"
tx, err := db.BeginTx(ctx, &sql.TxOptions{Isolation: sql.LevelSerializable})
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
_, err = tx.ExecContext(ctx, "stored_proc_name", orderRef)
if err != nil {