Releases: asifjalil/cli
Fixes issue #17
Do not consider SQL_SUCCESS_WITH_INFO success
success function in error.go was considering SQL_SUCCESS_WITH_INFO return code a success. As a result, this driver wasn't retrieving warnings. Fix that by only considering SQL_SUCCESS as a success.
Fixes issue #14
Fixes issue #14
Fixed issue #12
v1.2.6 Fixed issue #12
Disable DeferredPrepare
Assuming that when an application calls tx.PrepareContext(), it wants to execute SQLPrepare right away instead of the default DB2 CLI deferred behavior.
Chomp Database Error Message
Remove trailing newline from the database error message so if the database error is wrapped in another error message, we don't introduce a new line in the middle.
Query/QueryContext can return RowsAffected
Before calling database/sql.Exec/ExecContext and
database/sql.Query/QueryContext, one has to know the type of the query.
That is, if it is a statement that will produce a resultset, then use
Query/QueryContext. Otherwise, use Exec/ExecContext. Sometimes, a method
like JDBC's execute can be handy: A caller can use execute for all queries and use the
true/false to decide to check for resultset or update count. Go's
database/sql package currently does not provide such function.
This driver, for both sql.Exec/ExecContext and sql.Query/QueryContext
use the SQLExecute function from DB2 CLI. It then uses DB2 CLI's
SQLRowCount for sql.Result or SQLNumResultCols for sql.Rows.
This commit adds a hack that allows callers to use sql.Query/QueryContext for all
query type. When this driver finds that a query didn't produce a
resultset but there is a update count, it returns an error that has method RowsAffected(). Callers can check for that error and then use RowsAffected to get the update count.
Allow non-select statements to use sql.Query(...)
If non-select statements use the sql.DB.Query method, the driver throws an error that there is no resultset. Change that error to sql.ErrNoRows so an application can check and ignore it. This driver uses DB2 ODBC/CLI driver to interact with a database, and the DB2 driver handles the non-select statement fine when it is executed using the Query method.
Fixed issue #8
column.getData needs to set c.len to the "total" buffer size. Otherwise, we will return truncated data. SQLGetData sets c.len to the number of bytes that are copied to the output buffer. That's correct if the output buffer is big enough and the output data isn't truncated. If the data is truncated, we call SQLGetData in a loop until we get all the data. Each call to SQLGetData sets c.len to the number of bytes fetched. In the end, c.len is not the total number of bytes fetched. Instead, it is the amount of bytes fetched during the last call to SQLGetData. When we return the data to the application, we only return up to c.len. Since c.len is not the total size, the returned data is truncated. Fix it by setting c.len to the total number of bytes fetched before returning from column.getData(...).
Supports sql.Out
The driver now supports sql.Out for retrieving INOUT and OUT value parameters from stored procedures.