Skip to content

Commit

Permalink
Merge pull request #34 from fpco/binding-params
Browse files Browse the repository at this point in the history
Add binding of parameters for text/binary
  • Loading branch information
chrisdone authored Mar 31, 2021
2 parents 8fd9f92 + bbcbcf2 commit 671f190
Show file tree
Hide file tree
Showing 6 changed files with 315 additions and 51 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,3 +149,9 @@ for C/en_AU.UTF-8/C/C/C/C
```

use driver 13 or [see here for more detail](https://github.com/fpco/odbc/issues/17).

## Contributors

* Spencer Janssen
* Yo Eight
* Marco Z
35 changes: 34 additions & 1 deletion cbits/odbc.c
Original file line number Diff line number Diff line change
Expand Up @@ -159,12 +159,45 @@ void odbc_SQLFreeStmt(SQLHSTMT *hstmt){
}
}

////////////////////////////////////////////////////////////////////////////////
// Params

SQLRETURN odbc_SQLBindParameter(
EnvAndDbc* envAndDbc,
SQLHSTMT* statement_handle,
SQLUSMALLINT parameter_number,
SQLSMALLINT value_type,
SQLSMALLINT parameter_type,
SQLULEN column_size,
SQLPOINTER parameter_value_ptr,
SQLLEN buffer_length,
SQLLEN* buffer_length_ptr
) {
RETCODE r = SQLBindParameter(
*statement_handle,
parameter_number,
SQL_PARAM_INPUT,
value_type,
parameter_type,
column_size,
0,
parameter_value_ptr,
buffer_length,
buffer_length_ptr
);
if (r == SQL_ERROR)
odbc_ProcessLogMessages(envAndDbc, SQL_HANDLE_STMT, *statement_handle, "odbc_SQLBindParameter", FALSE);
return r;
}

////////////////////////////////////////////////////////////////////////////////
// Execute

RETCODE odbc_SQLExecDirectW(EnvAndDbc *envAndDbc, SQLHSTMT *hstmt, SQLWCHAR *stmt, SQLINTEGER len){
RETCODE r = SQLExecDirectW(*hstmt, stmt, len);
if (r == SQL_ERROR) odbc_ProcessLogMessages(envAndDbc, SQL_HANDLE_STMT, *hstmt, "odbc_SQLExecDirectW", FALSE);
if (r == SQL_ERROR) {
odbc_ProcessLogMessages(envAndDbc, SQL_HANDLE_STMT, *hstmt, "odbc_SQLExecDirectW", FALSE);
}
return r;
}

Expand Down
2 changes: 1 addition & 1 deletion odbc.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ description: Haskell binding to the ODBC API. This has been tested
suite runs on OS X, Windows and Linux.
copyright: FP Complete 2018
maintainer: [email protected]
version: 0.2.3
version: 0.2.4
license: BSD3
license-file: LICENSE
build-type: Simple
Expand Down
Loading

0 comments on commit 671f190

Please sign in to comment.