@@ -71,4 +71,44 @@ example, comparing MySQL, PostgreSQL, and Oracle:
71
71
WHERE col = ? WHERE col = $1 WHERE col = :col
72
72
VALUES(?, ?, ?) VALUES($1, $2, $3) VALUES(:val1, :val2, :val3)
73
73
74
+ Multiple Result Sets
75
+ ====================
76
+
77
+ The Go driver doesn't support multiple result sets from a single query in any
78
+ way, and there doesn't seem to be any plan to do that, although there is [ a
79
+ feature request] ( https://code.google.com/p/go/issues/detail?id=5171 ) for
80
+ supporting bulk operations such as bulk copy.
81
+
82
+ This means, among other things, that a stored procedure that returns multiple
83
+ result sets will not work correctly.
84
+
85
+ Invoking Stored Procedures
86
+ ==========================
87
+
88
+ Invoking stored procedures is driver-specific, but in the MySQL driver it can't
89
+ be done at present. It might seem that you'd be able to call a simple
90
+ procedure that returns a single result set, by executing something like this:
91
+
92
+ err := db.QueryRow("CALL mydb.myprocedure").Scan(&result)
93
+
94
+ In fact, this won't work. You'll get the following error: _ Error
95
+ 1312: PROCEDURE mydb.myprocedure can't return a result set in the given
96
+ context_ . This is because MySQL expects the connection to be set into
97
+ multi-statement mode, even for a single result, and the driver doesn't currently
98
+ do that.
99
+
100
+ Multiple Statement Support
101
+ ==========================
102
+
103
+ The ` database/sql ` doesn't offer multiple-statement support. That means you
104
+ can't do something like the following:
105
+
106
+ _, err := db.Exec("DELETE FROM tbl1; DELETE FROM tbl2")
107
+
108
+ Similarly, there is no way to batch statements in a transaction. Each statement
109
+ in a transaction must be executed serially, and the resources that it holds
110
+ (such as a Result or Rows) must be closed so the underlying connection is free
111
+ for another statement to use. This means that each statement in a transaction
112
+ results in a separate set of network round-trips to the database.
113
+
74
114
{% include toc.md %}
0 commit comments