From 66c6cede2b5039ca05ad57d3da3b76a5b8e9da47 Mon Sep 17 00:00:00 2001 From: Bernard Duggan Date: Wed, 25 Jul 2012 17:36:40 +1000 Subject: Add extended_errors option to ODBC This patch adds the extended_errors option to odbc:connect/2. When enabled, this option alters the return code of ODBC operations that produce errors to include the ODBC error code as well as the native error code, in addition to the ODBC reason field which is returned by default. The extended error information can be used to produce more sophisticated error handling than is possible with the standard ODBC Reason alone. --- lib/odbc/src/odbc.erl | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'lib/odbc/src/odbc.erl') diff --git a/lib/odbc/src/odbc.erl b/lib/odbc/src/odbc.erl index 16fdb4aabd..3eabec9ec3 100644 --- a/lib/odbc/src/odbc.erl +++ b/lib/odbc/src/odbc.erl @@ -810,10 +810,11 @@ connect(ConnectionReferense, ConnectionStr, Options) -> {C_TupleRow, _} = connection_config(tuple_row, Options), {BinaryStrings, _} = connection_config(binary_strings, Options), + {ExtendedErrors, _} = connection_config(extended_errors, Options), ODBCCmd = [?OPEN_CONNECTION, C_AutoCommitMode, C_TraceDriver, - C_SrollableCursors, C_TupleRow, BinaryStrings, ConnectionStr], + C_SrollableCursors, C_TupleRow, BinaryStrings, ExtendedErrors, ConnectionStr], %% Send request, to open a database connection, to the control process. case call(ConnectionReferense, @@ -860,6 +861,8 @@ connection_default(trace_driver) -> connection_default(scrollable_cursors) -> {?ON, on}; connection_default(binary_strings) -> + {?OFF, off}; +connection_default(extended_errors) -> {?OFF, off}. %%------------------------------------------------------------------------- -- cgit v1.2.3