Skip to content

Commit

Permalink
improve SQLBindCol
Browse files Browse the repository at this point in the history
  • Loading branch information
artpaul committed Sep 1, 2017
1 parent d1d3d33 commit 295f92d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
8 changes: 4 additions & 4 deletions driver/attr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,6 @@ impl_SQLSetStmtAttr(SQLHSTMT statement_handle, SQLINTEGER attribute,
case SQL_ATTR_PARAMSET_SIZE:
case SQL_ATTR_QUERY_TIMEOUT:
case SQL_ATTR_RETRIEVE_DATA:
case SQL_ATTR_ROW_BIND_OFFSET_PTR:
case SQL_ATTR_ROW_BIND_TYPE:
case SQL_ATTR_ROW_NUMBER:
case SQL_ATTR_ROW_OPERATION_PTR:
case SQL_ATTR_ROW_STATUS_PTR: /// Libreoffice Base
Expand All @@ -226,6 +224,8 @@ impl_SQLSetStmtAttr(SQLHSTMT statement_handle, SQLINTEGER attribute,
case SQL_ATTR_IMP_PARAM_DESC: /* 10013 (read-only) */
return SQL_ERROR;

case SQL_ATTR_ROW_BIND_OFFSET_PTR:
case SQL_ATTR_ROW_BIND_TYPE:
default:
throw std::runtime_error("Unsupported statement attribute.");
}
Expand Down Expand Up @@ -286,6 +286,8 @@ impl_SQLGetStmtAttr(SQLHSTMT statement_handle, SQLINTEGER attribute,
CASE_NUM(SQL_ATTR_QUERY_TIMEOUT, SQLULEN, 0);
CASE_NUM(SQL_ATTR_RETRIEVE_DATA, SQLULEN, SQL_RD_ON);
CASE_NUM(SQL_ATTR_ROW_NUMBER, SQLULEN, statement.result.getNumRows());
CASE_NUM(SQL_ATTR_USE_BOOKMARKS, SQLULEN, SQL_UB_OFF);
CASE_NUM(SQL_ATTR_ROW_BIND_TYPE, SQLULEN, SQL_BIND_TYPE_DEFAULT);

case SQL_ATTR_FETCH_BOOKMARK_PTR:
case SQL_ATTR_KEYSET_SIZE:
Expand All @@ -296,13 +298,11 @@ impl_SQLGetStmtAttr(SQLHSTMT statement_handle, SQLINTEGER attribute,
case SQL_ATTR_PARAMS_PROCESSED_PTR:
case SQL_ATTR_PARAMSET_SIZE:
case SQL_ATTR_ROW_BIND_OFFSET_PTR:
case SQL_ATTR_ROW_BIND_TYPE: /// TODO
case SQL_ATTR_ROW_OPERATION_PTR:
case SQL_ATTR_ROW_STATUS_PTR:
case SQL_ATTR_ROWS_FETCHED_PTR:
case SQL_ATTR_ROW_ARRAY_SIZE:
case SQL_ATTR_SIMULATE_CURSOR:
case SQL_ATTR_USE_BOOKMARKS: /// Libreoffice Base
default:
throw std::runtime_error("Unsupported statement attribute.");
}
Expand Down
11 changes: 10 additions & 1 deletion driver/odbc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,16 @@ SQLBindCol(HSTMT statement_handle,
return doWith<Statement>(statement_handle, [&](Statement & statement)
{
if (column_number < 1 || column_number > statement.result.getNumColumns())
throw std::runtime_error("Column number is out of range.");
throw SqlException("Column number is out of range", "07009");
if (out_value_max_size < 0)
throw SqlException("Invalid string or buffer length", "HY090");

// Unbinding column
if (out_value_size_or_indicator == nullptr)
{
statement.bindings.erase(column_number);
return SQL_SUCCESS;
}

if (target_type == SQL_C_DEFAULT)
{
Expand Down

0 comments on commit 295f92d

Please sign in to comment.