odbc_sys/
functions.rs

1use crate::{
2    BulkOperation, CDataType, Char, CompletionType, ConnectionAttribute, Desc, DriverConnectOption,
3    EnvironmentAttribute, FetchOrientation, FreeStmtOption, HDbc, HDesc, HEnv, HStmt, HWnd, Handle,
4    HandleType, InfoType, Integer, Len, Lock, Nullability, Operation, ParamType, Pointer, RetCode,
5    SetPosIRow, SmallInt, SqlDataType, SqlReturn, StatementAttribute, ULen, USmallInt, WChar,
6};
7
8pub static mut NUM_ENVIRONMENT: u32 = 0;
9
10// static linking is not currently supported here for windows
11#[cfg_attr(windows, link(name = "odbc32"))]
12#[cfg_attr(
13    all(not(windows), not(feature = "static"), not(feature = "iodbc")),
14    link(name = "odbc")
15)]
16#[cfg_attr(
17    all(not(windows), feature = "static", not(feature = "iodbc")),
18    link(name = "odbc", kind = "static")
19)]
20#[cfg_attr(
21    all(not(windows), not(feature = "static"), feature = "iodbc"),
22    link(name = "iodbc")
23)]
24#[cfg_attr(
25    all(not(windows), feature = "static", feature = "iodbc"),
26    link(name = "iodbc", kind = "static")
27)]
28extern "system" {
29    /// Allocates an environment, connection, statement, or descriptor handle.
30    ///
31    /// # Returns
32    /// `SUCCESS`, `SUCCESS_WITH_INFO`, `ERROR`, or `INVALID_HANDLE`
33    pub fn SQLAllocHandle(
34        handle_type: HandleType,
35        input_handle: Handle,
36        output_handle: *mut Handle,
37    ) -> SqlReturn;
38
39    /// Frees resources associated with a specific environment, connection, statement, or
40    /// descriptor handle.
41    ///
42    /// If `SQL_ERRQR` is returned the handle is still valid.
43    /// # Returns
44    /// `SUCCESS`, `ERROR`, or `INVALID_HANDLE`
45    pub fn SQLFreeHandle(handle_type: HandleType, handle: Handle) -> SqlReturn;
46
47    /// Gets attributes that govern aspects of environments
48    ///
49    /// # Returns
50    /// `SUCCESS`, `SUCCESS_WITH_INFO`, `ERROR`, or `INVALID_HANDLE`
51    pub fn SQLGetEnvAttr(
52        environment_handle: HEnv,
53        attribute: EnvironmentAttribute,
54        value_ptr: Pointer,
55        buffer_length: Integer,
56        string_length: *mut Integer,
57    ) -> SqlReturn;
58
59    /// Sets attributes that govern aspects of environments
60    ///
61    /// # Returns
62    /// `SUCCESS`, `SUCCESS_WITH_INFO`, `ERROR`, or `INVALID_HANDLE`
63    pub fn SQLSetEnvAttr(
64        environment_handle: HEnv,
65        attribute: EnvironmentAttribute,
66        value: Pointer,
67        string_length: Integer,
68    ) -> SqlReturn;
69
70    /// Closes the connection associated with a specific connection handle.
71    ///
72    /// # Returns
73    /// `SUCCESS`, `SUCCESS_WITH_INFO`, `ERROR`, or `INVALID_HANDLE`
74    pub fn SQLDisconnect(connection_handle: HDbc) -> SqlReturn;
75
76    /// Return the current values of multiple fields of a diagnostic record that contains eror,
77    /// warning, and status information.
78    ///
79    /// # Returns
80    ///
81    /// `SUCCESS`, `SUCCESS_WITH_INFO`, `ERROR`, or `INVALID_HANDLE`
82    pub fn SQLGetDiagRec(
83        handle_type: HandleType,
84        handle: Handle,
85        RecNumber: SmallInt,
86        state: *mut Char,
87        native_error_ptr: *mut Integer,
88        message_text: *mut Char,
89        buffer_length: SmallInt,
90        text_length_ptr: *mut SmallInt,
91    ) -> SqlReturn;
92
93    /// Return the current values of multiple fields of a diagnostic record that contains eror,
94    /// warning, and status information.
95    ///
96    /// # Returns
97    ///
98    /// `SUCCESS`, `SUCCESS_WITH_INFO`, `ERROR`, or `INVALID_HANDLE`
99    pub fn SQLGetDiagRecW(
100        handle_type: HandleType,
101        handle: Handle,
102        record_number: SmallInt,
103        state: *mut WChar,
104        native_error_ptr: *mut Integer,
105        message_text: *mut WChar,
106        buffer_length: SmallInt,
107        text_length_ptr: *mut SmallInt,
108    ) -> SqlReturn;
109
110    /// Returns the current value of a field of a record of the diagnostic data structure (associated with a specified handle) that contains error, warning, and status information.
111    ///
112    /// Note:
113    /// `diag_identifier` is either `SqlHeaderDiagnosticIdentifier` or `SqlDynamicDiagnosticIdentifier`
114    /// # Returns
115    /// `SUCCESS`, `SUCCESS_WITH_INFO`, `ERROR`, `INVALID_HANDLE`, or `SQL_NO_DATA`.
116    pub fn SQLGetDiagFieldW(
117        handle_type: HandleType,
118        handle: Handle,
119        record_number: SmallInt,
120        diag_identifier: SmallInt,
121        diag_info_ptr: Pointer,
122        buffer_length: SmallInt,
123        string_length_ptr: *mut SmallInt,
124    ) -> SqlReturn;
125
126    /// Executes a preparable statement, using the current values of the parameter marker variables
127    /// if any parameters exist in the statement. This is the fastest way to submit an SQL
128    /// statement for one-time execution
129    ///
130    /// # Returns
131    /// `SUCCESS`, `SUCCESS_WITH_INFO`, `SQL_NEED_DATA`, `SQL_STILL_EXECUTING`, `ERROR`
132    /// , `SQL_NO_DATA`, `INVALID_HANDLE`, or `SQL_PARAM_DATA_AVAILABLE`.
133    pub fn SQLExecDirect(
134        statement_handle: HStmt,
135        statement_text: *const Char,
136        text_length: Integer,
137    ) -> SqlReturn;
138
139    /// Executes a preparable statement, using the current values of the parameter marker variables
140    /// if any parameters exist in the statement. This is the fastest way to submit an SQL
141    /// statement for one-time execution
142    ///
143    /// # Returns
144    /// `SUCCESS`, `SUCCESS_WITH_INFO`, `SQL_NEED_DATA`, `SQL_STILL_EXECUTING`, `ERROR`
145    /// , `SQL_NO_DATA`, `INVALID_HANDLE`, or `SQL_PARAM_DATA_AVAILABLE`.
146    pub fn SQLExecDirectW(
147        statement_handle: HStmt,
148        statement_text: *const WChar,
149        text_length: Integer,
150    ) -> SqlReturn;
151
152    /// Returns the number of columns in a result set
153    ///
154    /// # Returns
155    /// `SUCCESS`, `SUCCESS_WITH_INFO`, `ERROR`, `INVALID_HANDLE` or `SQL_STILL_EXECUTING`
156    pub fn SQLNumResultCols(statement_handle: HStmt, column_count_ptr: *mut SmallInt) -> SqlReturn;
157
158    /// Returns the number of parameters in an SQL statement.
159    ///
160    /// # Returns
161    /// `SUCCESS`, `SUCCESS_WITH_INFO`, `ERROR`, `INVALID_HANDLE` or `SQL_STILL_EXECUTING`
162    pub fn SQLNumParams(statement_handle: HStmt, parameter_count_ptr: *mut SmallInt) -> SqlReturn;
163
164    /// Determines whether more results are available on a statement
165    /// containing SELECT, UPDATE, INSERT, or DELETE statements and, if so, initializes processing
166    /// for those results.
167    ///
168    /// # Returns
169    /// `SUCCESS`, `SUCCESS_WITH_INFO`, `SQL_STILL_EXECUTING`, `SQL_NO_DATA`, `ERROR`,
170    /// `INVALID_HANDLE`, or `SQL_PARAM_DATA_AVAILABLE`.
171    pub fn SQLMoreResults(statement_handle: HStmt) -> SqlReturn;
172
173    // Can be used since odbc version 3.8 to stream results
174    pub fn SQLGetData(
175        statement_handle: HStmt,
176        col_or_param_num: USmallInt,
177        target_type: CDataType,
178        target_value_ptr: Pointer,
179        buffer_length: Len,
180        str_len_or_ind_ptr: *mut Len,
181    ) -> SqlReturn;
182
183    /// SQLGetTypeInfo returns information about data types supported by the data source.
184    /// The driver returns the information in the form of an SQL result set.
185    /// The data types are intended for use in Data Definition Language (DDL) statements.
186    ///
187    /// # Returns
188    /// `SUCCESS`, `SUCCESS_WITH_INFO`, `SQL_STILL_EXECUTING`, `ERROR`, or `INVALID_HANDLE`.
189    pub fn SQLGetTypeInfo(statement_handle: HStmt, data_type: SqlDataType) -> SqlReturn;
190
191    /// SQLFetch fetches the next rowset of data from the result set and returns data for all bound
192    /// columns.
193    ///
194    /// # Returns
195    /// `SUCCESS`, `SUCCESS_WITH_INFO`, `ERROR`, `INVALID_HANDLE`, `SQL_NO_DATA` or
196    /// `SQL_STILL_EXECUTING`
197    pub fn SQLFetch(statement_handle: HStmt) -> SqlReturn;
198
199    /// Returns general information about the driver and data source associated with a connection
200    ///
201    /// # Returns
202    /// `SUCCESS`, `SUCCESS_WITH_INFO`, `ERROR`, or `INVALID_HANDLE`
203    pub fn SQLGetInfo(
204        connection_handle: HDbc,
205        info_type: InfoType,
206        info_value_ptr: Pointer,
207        buffer_length: SmallInt,
208        string_length_ptr: *mut SmallInt,
209    ) -> SqlReturn;
210
211    /// Returns general information about the driver and data source associated with a connection
212    ///
213    /// # Returns
214    /// `SUCCESS`, `SUCCESS_WITH_INFO`, `ERROR`, or `INVALID_HANDLE`
215    pub fn SQLGetInfoW(
216        connection_handle: HDbc,
217        info_type: InfoType,
218        info_value_ptr: Pointer,
219        buffer_length: SmallInt,
220        string_length_ptr: *mut SmallInt,
221    ) -> SqlReturn;
222
223    /// SQLConnect establishes connections to a driver and a data source. The connection handle
224    /// references storage of all information about the connection to the data source, including
225    /// status, transaction state, and error information.
226    ///
227    /// # Returns
228    /// `SUCCESS`, `SUCCESS_WITH_INFO`, `ERROR`, `INVALID_HANDLE`, or
229    /// `SQL_STILL_EXECUTING`
230    pub fn SQLConnectW(
231        connection_handle: HDbc,
232        server_name: *const WChar,
233        name_length_1: SmallInt,
234        user_name: *const WChar,
235        name_length_2: SmallInt,
236        authentication: *const WChar,
237        name_length_3: SmallInt,
238    ) -> SqlReturn;
239
240    /// SQLConnect establishes connections to a driver and a data source. The connection handle
241    /// references storage of all information about the connection to the data source, including
242    /// status, transaction state, and error information.
243    ///
244    /// # Returns
245    /// `SUCCESS`, `SUCCESS_WITH_INFO`, `ERROR`, `INVALID_HANDLE`, or
246    /// `SQL_STILL_EXECUTING`
247    pub fn SQLConnect(
248        connection_handle: HDbc,
249        server_name: *const Char,
250        name_length_1: SmallInt,
251        user_name: *const Char,
252        name_length_2: SmallInt,
253        authentication: *const Char,
254        name_length_3: SmallInt,
255    ) -> SqlReturn;
256
257    /// Returns the list of table, catalog, or schema names, and table types, stored in a specific
258    /// data source. The driver returns the information as a result set
259    ///
260    /// # Returns
261    /// `SUCCESS`, `SUCCESS_WITH_INFO`, `ERROR`, `INVALID_HANDLE`, or
262    /// `SQL_STILL_EXECUTING`
263    pub fn SQLTables(
264        statement_handle: HStmt,
265        catalog_name: *const Char,
266        name_length_1: SmallInt,
267        schema_name: *const Char,
268        name_length_2: SmallInt,
269        table_name: *const Char,
270        name_length_3: SmallInt,
271        table_type: *const Char,
272        name_length_4: SmallInt,
273    ) -> SqlReturn;
274
275    /// Returns the list of table, catalog, or schema names, and table types, stored in a specific
276    /// data source. The driver returns the information as a result set
277    ///
278    /// # Returns
279    /// `SUCCESS`, `SUCCESS_WITH_INFO`, `ERROR`, `INVALID_HANDLE`, or
280    /// `SQL_STILL_EXECUTING`
281    pub fn SQLTablesW(
282        statement_handle: HStmt,
283        catalog_name: *const WChar,
284        name_length_1: SmallInt,
285        schema_name: *const WChar,
286        name_length_2: SmallInt,
287        table_name: *const WChar,
288        name_length_3: SmallInt,
289        table_type: *const WChar,
290        name_length_4: SmallInt,
291    ) -> SqlReturn;
292
293    /// Returns information about a data source. This function is implemented only by the Driver
294    /// Manager.
295    ///
296    /// # Returns
297    /// `SUCCESS`, `SUCCESS_WITH_INFO`, `ERROR`, `INVALID_HANDLE`, or `SQL_NO_DATA`
298    pub fn SQLDataSources(
299        environment_handle: HEnv,
300        direction: FetchOrientation,
301        server_name: *mut Char,
302        buffer_length_1: SmallInt,
303        name_length_1: *mut SmallInt,
304        description: *mut Char,
305        buffer_length_2: SmallInt,
306        name_length_2: *mut SmallInt,
307    ) -> SqlReturn;
308
309    /// Returns information about a data source. This function is implemented only by the Driver
310    /// Manager.
311    ///
312    /// # Returns
313    /// `SUCCESS`, `SUCCESS_WITH_INFO`, `ERROR`, `INVALID_HANDLE`, or `SQL_NO_DATA`
314    pub fn SQLDataSourcesW(
315        environment_handle: HEnv,
316        direction: FetchOrientation,
317        server_name: *mut WChar,
318        buffer_length_1: SmallInt,
319        name_length_1: *mut SmallInt,
320        description: *mut WChar,
321        buffer_length_2: SmallInt,
322        name_length_2: *mut SmallInt,
323    ) -> SqlReturn;
324
325    /// An alternative to `SQLConnect`. It supports data sources that require more connection
326    /// information than the three arguments in `SQLConnect`, dialog boxes to prompt the user for
327    /// all connection information, and data sources that are not defined in the system information
328    ///
329    /// # Returns
330    /// `SUCCESS`, `SUCCESS_WITH_INFO`, `ERROR`, `INVALID_HANDLE`, `SQL_NO_DATA`,
331    /// or `SQL_STILL_EXECUTING`
332    pub fn SQLDriverConnect(
333        connection_handle: HDbc,
334        window_handle: HWnd,
335        in_connection_string: *const Char,
336        string_length_1: SmallInt,
337        out_connection_string: *mut Char,
338        buffer_length: SmallInt,
339        string_length_2: *mut SmallInt,
340        DriverCompletion: DriverConnectOption,
341    ) -> SqlReturn;
342
343    /// An alternative to `SQLConnect`. It supports data sources that require more connection
344    /// information than the three arguments in `SQLConnect`, dialog boxes to prompt the user for
345    /// all connection information, and data sources that are not defined in the system information
346    ///
347    /// # Returns
348    /// `SUCCESS`, `SUCCESS_WITH_INFO`, `ERROR`, `INVALID_HANDLE`, `SQL_NO_DATA`,
349    /// or `SQL_STILL_EXECUTING`
350    pub fn SQLDriverConnectW(
351        connection_handle: HDbc,
352        window_handle: HWnd,
353        in_connection_string: *const WChar,
354        string_length_1: SmallInt,
355        out_connection_string: *mut WChar,
356        buffer_length: SmallInt,
357        string_length_2: *mut SmallInt,
358        driver_completion: DriverConnectOption,
359    ) -> SqlReturn;
360
361    /// Lists driver descriptions and driver attribute keywords. This function is implemented only
362    /// by the Driver Manager.
363    ///
364    /// # Returns
365    /// `SUCCESS`, `SUCCESS_WITH_INFO`, `ERROR`, `INVALID_HANDLE`, or `SQL_NO_DATA`
366    pub fn SQLDrivers(
367        henv: HEnv,
368        direction: FetchOrientation,
369        driver_desc: *mut Char,
370        driver_desc_max: SmallInt,
371        out_driver_desc: *mut SmallInt,
372        driver_attributes: *mut Char,
373        drvr_attr_max: SmallInt,
374        out_drvr_attr: *mut SmallInt,
375    ) -> SqlReturn;
376
377    /// Lists driver descriptions and driver attribute keywords. This function is implemented only
378    /// by the Driver Manager.
379    ///
380    /// # Returns
381    /// `SUCCESS`, `SUCCESS_WITH_INFO`, `ERROR`, `INVALID_HANDLE`, or `SQL_NO_DATA`
382    pub fn SQLDriversW(
383        henv: HEnv,
384        direction: FetchOrientation,
385        driver_desc: *mut WChar,
386        driver_desc_max: SmallInt,
387        out_driver_desc: *mut SmallInt,
388        driver_attributes: *mut WChar,
389        drvr_attr_max: SmallInt,
390        out_drvr_attr: *mut SmallInt,
391    ) -> SqlReturn;
392
393    /// Closes a cursor that has been opened on a statement and discards pending results.
394    ///
395    /// # Returns
396    /// `SUCCESS`, `SUCCESS_WITH_INFO`, `ERROR` or `INVALID_HANDLE`
397    pub fn SQLCloseCursor(hstmt: HStmt) -> SqlReturn;
398
399    /// Binds a buffer to a parameter marker in an SQL statement
400    ///
401    /// # Returns
402    /// `SUCCESS`, `SUCCESS_WITH_INFO`, `ERROR` or `INVALID_HANDLE`
403    pub fn SQLBindParameter(
404        hstmt: HStmt,
405        parameter_number: USmallInt,
406        input_output_type: ParamType,
407        value_type: CDataType,
408        parameter_type: SqlDataType,
409        column_size: ULen,
410        decimal_digits: SmallInt,
411        parameter_value_ptr: Pointer,
412        buffer_length: Len,
413        str_len_or_ind_ptr: *mut Len,
414    ) -> SqlReturn;
415
416    /// Performs bulk insertions and bulk bookmark operations, including update, delete, and fetch by bookmark.
417    ///
418    /// # Returns
419    /// `SUCCESS`, `SUCCESS_WITH_INFO`, `SQL_NEED_DATA`, `SQL_STILL_EXECUTING`, `ERROR`, or `INVALID_HANDLE`.
420    pub fn SQLBulkOperations(statement_handle: HStmt, operation: BulkOperation) -> SqlReturn;
421
422    /// Cancels the processing on a statement.
423    ///
424    /// # Returns
425    /// `SUCCESS`, `SUCCESS_WITH_INFO`, `ERROR` or `INVALID_HANDLE`
426    pub fn SQLCancel(statement_handle: HStmt) -> SqlReturn;
427
428    /// Cancels the processing on a connection or statement.
429    ///
430    /// # Returns
431    /// `SUCCESS`, `SUCCESS_WITH_INFO`, `ERROR` or `INVALID_HANDLE`
432    pub fn SQLCancelHandle(handle_type: HandleType, handle: Handle) -> SqlReturn;
433
434    /// Compiles the statement and generates an access plan.
435    ///
436    /// # Returns
437    /// `SUCCESS`, `SUCCESS_WITH_INFO`, `ERROR`, `INVALID_HANDLE`, or
438    /// `SQL_STILL_EXECUTING`
439    pub fn SQLPrepare(hstmt: HStmt, statement_text: *const Char, text_length: Integer)
440        -> SqlReturn;
441
442    /// Compiles the statement and generates an access plan.
443    ///
444    /// # Returns
445    /// `SUCCESS`, `SUCCESS_WITH_INFO`, `ERROR`, `INVALID_HANDLE`, or
446    /// `SQL_STILL_EXECUTING`
447    pub fn SQLPrepareW(
448        hstmt: HStmt,
449        statement_text: *const WChar,
450        text_length: Integer,
451    ) -> SqlReturn;
452
453    /// Executes a prepared statement, using the current values of the parameter marker variables
454    /// if any paramater markers exis in the statement.
455    ///
456    /// # Returns
457    /// `SUCCESS`, `SUCCESS_WITH_INFO`, `SQL_NEED_DATA`, `SQL_STILL_EXECUTING`, `ERROR`
458    /// , `SQL_NO_DATA`, `INVALID_HANDLE`, or `SQL_PARAM_DATA_AVAILABLE`.
459    pub fn SQLExecute(hstmt: HStmt) -> SqlReturn;
460
461    /// Stops processing associated with a specific statement, closes any open cursors associated
462    /// with the statement, discards pending results, or, optionally, frees all resources
463    /// associated with the statement handle.
464    ///
465    /// # Returns
466    /// `SUCCESS`, `SUCCESS_WITH_INFO`, `ERROR`, or `INVALID_HANDLE`.
467    pub fn SQLFreeStmt(hstmt: HStmt, option: FreeStmtOption) -> SqlReturn;
468
469    /// Binds application data bufferst to columns in the result set.
470    ///
471    /// # Returns
472    /// `SUCCESS`, `SUCCESS_WITH_INFO`, `ERROR`, or `INVALID_HANDLE`.
473    pub fn SQLBindCol(
474        hstmt: HStmt,
475        col_number: USmallInt,
476        target_type: CDataType,
477        target_value: Pointer,
478        buffer_length: Len,
479        length_or_indicator: *mut Len,
480    ) -> SqlReturn;
481
482    /// SQLBrowseConnect supports an iterative method of discovering and enumerating the attributes
483    /// and attribute values required to connect to a data source.
484    /// Each call to SQLBrowseConnect returns successive levels of attributes and attribute values.
485    ///
486    /// # Returns
487    /// `SUCCESS`, `SUCCESS_WITH_INFO`, `SQL_NEED_DATA`, `ERROR`, `INVALID_HANDLE`, or `SQL_STILL_EXECUTING`.
488    pub fn SQLBrowseConnectW(
489        connection_handle: HDbc,
490        in_connection_string: *const WChar,
491        string_length: SmallInt,
492        out_connection_string: *mut WChar,
493        buffer_length: SmallInt,
494        out_buffer_length: *mut SmallInt,
495    ) -> SqlReturn;
496
497    /// Returns descriptor information for a column in a result set. Descriptor information is
498    /// returned as a character string, a descriptor-dependent value, or an integer value.
499    ///
500    /// # Returns
501    /// `SUCCESS`, `SUCCESS_WITH_INFO`, `ERROR`, `INVALID_HANDLE`, or `SQL_STILL_EXECUTING`.
502    pub fn SQLColAttributeW(
503        statement_handle: HStmt,
504        column_number: USmallInt,
505        field_identifier: Desc,
506        character_attribute_ptr: Pointer,
507        buffer_length: SmallInt,
508        string_length_ptr: *mut SmallInt,
509        numeric_attribute_ptr: *mut Len,
510    ) -> SqlReturn;
511
512    /// Returns descriptor information for a column in a result set. Descriptor information is
513    /// returned as a character string, a descriptor-dependent value, or an integer value.
514    ///
515    /// # Returns
516    /// `SUCCESS`, `SUCCESS_WITH_INFO`, `ERROR`, `INVALID_HANDLE`, or `SQL_STILL_EXECUTING`.
517    pub fn SQLColAttribute(
518        statement_handle: HStmt,
519        column_number: USmallInt,
520        field_identifier: Desc,
521        character_attribute_ptr: Pointer,
522        buffer_length: SmallInt,
523        string_length_ptr: *mut SmallInt,
524        numeric_attribute_ptr: *mut Len,
525    ) -> SqlReturn;
526
527    /// Copies descriptor information from one descriptor handle to another.
528    ///
529    /// # Returns
530    /// `SUCCESS`, `ERROR`, `SQL_NO_DATA`, or `INVALID_HANDLE`.
531    pub fn SQLCopyDesc(source_desc_handle: HDesc, target_desc_handle: HDesc) -> SqlReturn;
532
533    /// Returns the current setting of a connection attribute.
534    ///
535    /// * `buffer_length`: is either buffer length or one of [`crate::IS_POINTER`],
536    ///   [`crate::IS_UINTEGER`], [`crate::IS_INTEGER`], [`crate::IS_USMALLINT`] or
537    ///   [`crate::IS_SMALLINT`].
538    ///
539    /// # Returns
540    /// `SUCCESS`, `ERROR`, `SQL_NO_DATA`, or `INVALID_HANDLE`.
541    pub fn SQLGetConnectAttr(
542        connection_handle: HDbc,
543        attribute: ConnectionAttribute,
544        value_ptr: Pointer,
545        buffer_length: Integer,
546        string_length_ptr: *mut Integer,
547    ) -> SqlReturn;
548
549    /// Returns the current setting of a connection attribute.
550    ///
551    /// * `buffer_length`: is either buffer length or one of [`crate::IS_POINTER`],
552    ///   [`crate::IS_UINTEGER`], [`crate::IS_INTEGER`], [`crate::IS_USMALLINT`] or
553    ///   [`crate::IS_SMALLINT`].
554    ///
555    /// # Returns
556    /// `SUCCESS`, `ERROR`, `SQL_NO_DATA`, or `INVALID_HANDLE`.
557    pub fn SQLGetConnectAttrW(
558        connection_handle: HDbc,
559        attribute: ConnectionAttribute,
560        value_ptr: Pointer,
561        buffer_length: Integer,
562        string_length_ptr: *mut Integer,
563    ) -> SqlReturn;
564
565    /// Returns the cursor name associated with a specified statement.
566    ///
567    /// # Returns
568    /// `SUCCESS`, `SUCCESS_WITH_INFO`, `ERROR`, or `INVALID_HANDLE`.
569    pub fn SQLGetCursorNameW(
570        statement_handle: HStmt,
571        cursor_name: *mut WChar,
572        buffer_length: SmallInt,
573        name_length_ptr: *mut SmallInt,
574    ) -> SqlReturn;
575
576    /// Returns the current setting or value of a single field of a descriptor record.
577    ///
578    /// # Returns
579    /// `SUCCESS`, `SUCCESS_WITH_INFO`, `ERROR`, `SQL_NO_DATA`, or `INVALID_HANDLE`.
580    /// `SQL_NO_DATA` is returned if RecNumber is greater than the current number of descriptor records.
581    /// `SQL_NO_DATA` is returned if DescriptorHandle is an IRD handle and the statement is in the prepared or executed state but there was no open cursor associated with it.
582    pub fn SQLGetDescFieldW(
583        descriptor_handle: HDesc,
584        record_number: SmallInt,
585        field_identifier: Desc,
586        value_ptr: Pointer,
587        buffer_length: Integer,
588        string_length_ptr: *mut Integer,
589    ) -> SqlReturn;
590
591    /// Returns the current settings or values of multiple fields of a descriptor record.
592    /// The fields returned describe the name, data type, and storage of column or parameter data.
593    ///
594    /// # Returns
595    /// `SUCCESS`, `SUCCESS_WITH_INFO`, `ERROR`, `SQL_NO_DATA`, or `INVALID_HANDLE`.
596    /// `SQL_NO_DATA` is returned if RecNumber is greater than the current number of descriptor records.
597    /// `SQL_NO_DATA` is returned if DescriptorHandle is an IRD handle and the statement is in the prepared or executed state but there was no open cursor associated with it.
598    pub fn SQLGetDescRecW(
599        descriptor_handle: HDesc,
600        record_number: SmallInt,
601        name: *mut WChar,
602        buffer_length: SmallInt,
603        string_length_ptr: *mut SmallInt,
604        type_ptr: *mut SmallInt,
605        sub_type_ptr: *mut SmallInt,
606        length_ptr: *mut Len,
607        precision_ptr: *mut SmallInt,
608        scale_ptr: *mut SmallInt,
609        nullable_ptr: *mut Nullability,
610    ) -> SqlReturn;
611
612    /// Returns a list of columns and associated privileges for the specified table.
613    /// The driver returns the information as a result set on the specified StatementHandle.
614    ///
615    /// # Returns
616    /// `SUCCESS`, `SUCCESS_WITH_INFO`, `ERROR`, `INVALID_HANDLE`, or `SQL_STILL_EXECUTING`.
617    pub fn SQLColumnPrivilegesW(
618        statement_handle: HStmt,
619        catalog_name: *const WChar,
620        catalog_name_length: SmallInt,
621        schema_name: *const WChar,
622        schema_name_length: SmallInt,
623        table_name: *const WChar,
624        table_name_length: SmallInt,
625        column_name: *const WChar,
626        column_name_length: SmallInt,
627    ) -> SqlReturn;
628
629    /// Returns the list of column names in specified tables. The driver returns this information as
630    /// a result set on the specified StatementHandle.
631    ///
632    /// # Returns
633    /// `SUCCESS`, `SUCCESS_WITH_INFO`, `ERROR`, `INVALID_HANDLE`, or `SQL_STILL_EXECUTING`.
634    pub fn SQLColumns(
635        statement_handle: HStmt,
636        catalog_name: *const Char,
637        catalog_name_length: SmallInt,
638        schema_name: *const Char,
639        schema_name_length: SmallInt,
640        table_name: *const Char,
641        table_name_length: SmallInt,
642        column_name: *const Char,
643        column_name_length: SmallInt,
644    ) -> SqlReturn;
645
646    /// Returns the list of column names in specified tables. The driver returns this information as
647    /// a result set on the specified StatementHandle.
648    ///
649    /// # Returns
650    /// `SUCCESS`, `SUCCESS_WITH_INFO`, `ERROR`, `INVALID_HANDLE`, or `SQL_STILL_EXECUTING`.
651    pub fn SQLColumnsW(
652        statement_handle: HStmt,
653        catalog_name: *const WChar,
654        catalog_name_length: SmallInt,
655        schema_name: *const WChar,
656        schema_name_length: SmallInt,
657        table_name: *const WChar,
658        table_name_length: SmallInt,
659        column_name: *const WChar,
660        column_name_length: SmallInt,
661    ) -> SqlReturn;
662
663    /// Can be used to determine when an asynchronous function is complete using either notification- or polling-based processing.
664    ///
665    /// # Returns
666    /// `SUCCESS`, `ERROR`, `SQL_NO_DATA`, or `INVALID_HANDLE`.
667    #[cfg(feature = "odbc_version_3_80")]
668    pub fn SQLCompleteAsync(
669        handle_type: HandleType,
670        handle: Handle,
671        async_ret_code_ptr: *mut RetCode,
672    ) -> SqlReturn;
673
674    /// Returns the current setting of a statement attribute.
675    ///
676    /// A call to `SQLGetStmtAttr` returns in `value` the value of the statement attribute specified
677    /// in `attribute`. That value can either be a `ULen` value or a null-terminated character
678    /// string. If the value is a `ULen` value, some drivers may only write the lower 32-bit or
679    /// 16-bit of a buffer and leave the higher-order bit unchanged. Therefore, applications should
680    /// use a buffer of `ULen and initialize the value to 0 before calling this function. Also, the
681    /// `buffer_length` and `string_length` arguments are not used. If the value is a
682    /// null-terminated string, the application specifies the maximum length of that string in the
683    /// `buffer_length` argument, and the driver returns the length of that string in the
684    /// `string_length` buffer.
685    ///
686    /// To allow applications calling `SQLGetStmtAttr` to work with ODBC 2.x drivers, a call to
687    /// `SQLGetStmtAttr` is mapped in the Driver Manager to SQLGetStmtOption.
688    /// The following statement attributes are read-only, so can be retrieved by `SQLGetStmtAttr`,
689    /// but not set by SQLSetStmtAttr:
690    ///
691    /// * `StatementAttribute::ImpParamDesc`
692    /// * `StatementAttribute::ImpRowDesc`
693    /// * `StatementAttribute::RowNumber`
694    ///
695    /// # Returns
696    ///
697    /// `SUCCESS`, `SUCCESS_WITH_INFO`, `ERROR`, or `INVALID_HANDLE`.
698    pub fn SQLGetStmtAttr(
699        hstmt: HStmt,
700        attribute: StatementAttribute,
701        value: Pointer,
702        buffer_length: Integer,
703        string_length: *mut Integer,
704    ) -> SqlReturn;
705
706    /// Returns the current setting of a statement attribute.
707    ///
708    /// A call to `SQLGetStmtAttr` returns in `value` the value of the statement attribute specified
709    /// in `attribute`. That value can either be a `ULen` value or a null-terminated character
710    /// string. If the value is a `ULen` value, some drivers may only write the lower 32-bit or
711    /// 16-bit of a buffer and leave the higher-order bit unchanged. Therefore, applications should
712    /// use a buffer of `ULen and initialize the value to 0 before calling this function. Also, the
713    /// `buffer_length` and `string_length` arguments are not used. If the value is a
714    /// null-terminated string, the application specifies the maximum length of that string in the
715    /// `buffer_length` argument, and the driver returns the length of that string in the
716    /// `string_length` buffer.
717    ///
718    /// To allow applications calling `SQLGetStmtAttr` to work with ODBC 2.x drivers, a call to
719    /// `SQLGetStmtAttr` is mapped in the Driver Manager to SQLGetStmtOption.
720    /// The following statement attributes are read-only, so can be retrieved by `SQLGetStmtAttr`,
721    /// but not set by SQLSetStmtAttr:
722    ///
723    /// * `StatementAttribute::ImpParamDesc`
724    /// * `StatementAttribute::ImpRowDesc`
725    /// * `StatementAttribute::RowNumber`
726    ///
727    /// # Returns
728    ///
729    /// `SUCCESS`, `SUCCESS_WITH_INFO`, `ERROR`, or `INVALID_HANDLE`.
730    pub fn SQLGetStmtAttrW(
731        handle: HStmt,
732        attribute: StatementAttribute,
733        value_ptr: Pointer,
734        buffer_length: Integer,
735        string_length_ptr: *mut Integer,
736    ) -> SqlReturn;
737
738    /// Fetches the specified rowset of data from the result set and returns data for all bound columns.
739    /// Rowsets can be specified at an absolute or relative position or by bookmark.
740    ///
741    /// # Returns
742    /// 
743    /// `SUCCESS`, `SUCCESS_WITH_INFO`, `ERROR`, `INVALID_HANDLE`, or `STILL_EXECUTING`.
744    pub fn SQLFetchScroll(
745        statement_handle: HStmt,
746        fetch_orientation: FetchOrientation,
747        fetch_offset: Len,
748    ) -> SqlReturn;
749
750    /// Sets the cursor position in a rowset and allows an application to refresh, update or delete
751    /// data in the rowset.
752    /// 
753    /// See: <https://learn.microsoft.com/sql/odbc/reference/syntax/sqlsetpos-function>
754    /// 
755    /// # Parameters
756    /// 
757    /// * `statement_handle`: Statement Handle
758    /// * `row_number`: Position of the row in the rowset on which to perform the operation
759    ///   specified with the Operation argument. If `row_number` is 0, the operation applies to
760    ///   every row in the rowset.
761    /// * `operation`: Operation to perform
762    /// * `lock_type`: Specifies how to lock the row after performing the operation specified in the
763    ///   Operation argument.
764    /// 
765    /// # Returns
766    /// 
767    /// `SUCCESS`, `SUCCESS_WITH_INFO`, `NEED_DATA`, `STILL_EXECUTING`, `ERROR`, or
768    /// `INVALID_HANDLE`.
769    pub fn SQLSetPos(
770        statement_handle: HStmt,
771        row_number: SetPosIRow,
772        operation: Operation,
773        lock_type: Lock,
774    ) -> SqlReturn;
775
776    /// Can return:
777    /// - A list of foreign keys in the specified table (columns in the specified table that refer to primary keys in other tables).
778    /// - A list of foreign keys in other tables that refer to the primary key in the specified table.
779    ///
780    /// The driver returns each list as a result set on the specified statement.
781    ///
782    /// # Returns
783    /// `SUCCESS`, `SUCCESS_WITH_INFO`, `ERROR`, `INVALID_HANDLE`, or `SQL_STILL_EXECUTING`.
784    pub fn SQLForeignKeys(
785        statement_handle: HStmt,
786        pk_catalog_name: *const Char,
787        pk_catalog_name_length: SmallInt,
788        pk_schema_name: *const Char,
789        pk_schema_name_length: SmallInt,
790        pk_table_name: *const Char,
791        pk_table_name_length: SmallInt,
792        fk_catalog_name: *const Char,
793        fk_catalog_name_length: SmallInt,
794        fk_schema_name: *const Char,
795        fk_schema_name_length: SmallInt,
796        fk_table_name: *const Char,
797        fk_table_name_length: SmallInt,
798    ) -> SqlReturn;
799
800    /// Can return:
801    /// - A list of foreign keys in the specified table (columns in the specified table that refer to primary keys in other tables).
802    /// - A list of foreign keys in other tables that refer to the primary key in the specified table.
803    ///
804    /// The driver returns each list as a result set on the specified statement.
805    ///
806    /// # Returns
807    /// `SUCCESS`, `SUCCESS_WITH_INFO`, `ERROR`, `INVALID_HANDLE`, or `SQL_STILL_EXECUTING`.
808    pub fn SQLForeignKeysW(
809        statement_handle: HStmt,
810        pk_catalog_name: *const WChar,
811        pk_catalog_name_length: SmallInt,
812        pk_schema_name: *const WChar,
813        pk_schema_name_length: SmallInt,
814        pk_table_name: *const WChar,
815        pk_table_name_length: SmallInt,
816        fk_catalog_name: *const WChar,
817        fk_catalog_name_length: SmallInt,
818        fk_schema_name: *const WChar,
819        fk_schema_name_length: SmallInt,
820        fk_table_name: *const WChar,
821        fk_table_name_length: SmallInt,
822    ) -> SqlReturn;
823
824    /// Returns the result descriptor for one column in the result set — column name, type, column
825    /// size, decimal digits, and nullability.
826    ///
827    /// This information also is available in the fields of the IRD.
828    ///
829    /// # Returns
830    /// `SUCCESS`, `SUCCESS_WITH_INFO`, `SQL_STILL_EXECUTING`, `ERROR`, or
831    /// `INVALID_HANDLE`.
832    pub fn SQLDescribeCol(
833        hstmt: HStmt,
834        col_number: USmallInt,
835        col_name: *mut Char,
836        buffer_length: SmallInt,
837        name_length: *mut SmallInt,
838        data_type: *mut SqlDataType,
839        col_size: *mut ULen,
840        decimal_digits: *mut SmallInt,
841        nullable: *mut Nullability,
842    ) -> SqlReturn;
843
844    /// Returns the result descriptor for one column in the result set — column name, type, column
845    /// size, decimal digits, and nullability.
846    ///
847    /// This information also is available in the fields of the IRD.
848    ///
849    /// # Returns
850    /// `SUCCESS`, `SUCCESS_WITH_INFO`, `SQL_STILL_EXECUTING`, `ERROR`, or
851    /// `INVALID_HANDLE`.
852    pub fn SQLDescribeColW(
853        hstmt: HStmt,
854        col_number: USmallInt,
855        col_name: *mut WChar,
856        buffer_length: SmallInt,
857        name_length: *mut SmallInt,
858        data_type: *mut SqlDataType,
859        col_size: *mut ULen,
860        decimal_digits: *mut SmallInt,
861        nullable: *mut Nullability,
862    ) -> SqlReturn;
863
864    /// Returns the description of a parameter marker associated with a prepared SQL statement.
865    /// This information is also available in the fields of the IPD.
866    ///
867    /// # Returns
868    ///
869    /// `SUCCESS`, `SUCCESS_WITH_INFO`, `SQL_STILL_EXECUTING`, `ERROR`, or
870    /// `INVALID_HANDLE`.
871    pub fn SQLDescribeParam(
872        statement_handle: HStmt,
873        parameter_number: USmallInt,
874        data_type_ptr: *mut SqlDataType,
875        parameter_size_ptr: *mut ULen,
876        decimal_digits_ptr: *mut SmallInt,
877        nullable_ptr: *mut Nullability,
878    ) -> SqlReturn;
879
880    /// Sets attributes related to a statement.
881    ///
882    /// # Returns
883    /// `SUCCESS`, `SUCCESS_WITH_INFO`, `ERROR`, or `INVALID_HANDLE`.
884    pub fn SQLSetStmtAttr(
885        hstmt: HStmt,
886        attr: StatementAttribute,
887        value: Pointer,
888        str_length: Integer,
889    ) -> SqlReturn;
890
891    /// Sets attributes related to a statement.
892    ///
893    /// # Returns
894    /// `SUCCESS`, `SUCCESS_WITH_INFO`, `ERROR`, or `INVALID_HANDLE`.
895    pub fn SQLSetStmtAttrW(
896        hstmt: HStmt,
897        attr: StatementAttribute,
898        value: Pointer,
899        str_length: Integer,
900    ) -> SqlReturn;
901
902    /// Sets attributes that govern aspects of connections.
903    ///
904    /// # Returns
905    /// `SUCCESS`, `SUCCESS_WITH_INFO`, `ERROR`, `INVALID_HANDLE`, or `SQL_STILL_EXECUTING`.
906    pub fn SQLSetConnectAttr(
907        hdbc: HDbc,
908        attr: ConnectionAttribute,
909        value: Pointer,
910        str_length: Integer,
911    ) -> SqlReturn;
912
913    /// Sets attributes that govern aspects of connections.
914    ///
915    /// # Returns
916    ///
917    /// `SUCCESS`, `SUCCESS_WITH_INFO`, `ERROR`, `INVALID_HANDLE`, or `SQL_STILL_EXECUTING`.
918    pub fn SQLSetConnectAttrW(
919        hdbc: HDbc,
920        attr: ConnectionAttribute,
921        value: Pointer,
922        str_length: Integer,
923    ) -> SqlReturn;
924
925    /// Requests a commit or rollback operation for all active operations on all statements associated with a handle.
926    ///
927    /// # Returns
928    ///
929    /// `SUCCESS`, `SUCCESS_WITH_INFO`, `ERROR`, `INVALID_HANDLE`, or `SQL_STILL_EXECUTING`.
930    pub fn SQLEndTran(
931        handle_type: HandleType,
932        handle: Handle,
933        completion_type: CompletionType,
934    ) -> SqlReturn;
935
936    /// Returns the number of rows affected by an UPDATE, INSERT, or DELETE statement; an `SQL_ADD`,
937    /// `SQL_UPDATE_BY_BOOKMARK`, or `SQL_DELETE_BY_BOOKMARK` operation in SQLBulkOperations; or an
938    /// `SQL_UPDATE` or `SQL_DELETE` operation in `SQLSetPos`.
939    ///
940    /// # Returns
941    /// `SUCCESS`, `SUCCESS_WITH_INFO`, `INVALID_HANDLE`, or `ERROR`.
942    pub fn SQLRowCount(hstmt: HStmt, row_count: *mut Len) -> SqlReturn;
943
944    /// Allows an application to send data for a parameter or column to the driver at statement
945    /// execution time. This function can be used to send character or binary data values in parts
946    /// to a column with a character, binary, or data source-specific data type (for example,
947    /// parameters of the SQL_LONGVARBINARY or SQL_LONGVARCHAR types). SQLPutData supports binding
948    /// to a Unicode C data type, even if the underlying driver does not support Unicode data.
949    ///
950    /// # Returns
951    ///
952    /// `SUCCESS`, `SUCCESS_WITH_INFO`, `STILL_EXECUTING`, `ERROR`, or `INVALID_HANDLE`.
953    pub fn SQLPutData(hstmt: HStmt, data: Pointer, str_len_or_ind: Len) -> SqlReturn;
954
955    /// Sets the value of a single field of a descriptor record.
956    ///
957    /// # Returns
958    ///
959    /// `SUCCESS`, `SUCCESS_WITH_INFO`, `ERROR`, or `INVALID_HANDLE`.
960    pub fn SQLSetDescField(
961        hdesc: HDesc,
962        rec_number: SmallInt,
963        field_identifier: Desc,
964        value: Pointer,
965        buffer_length: Integer,
966    ) -> SqlReturn;
967
968    /// Sets the value of a single field of a descriptor record.
969    ///
970    /// # Returns
971    ///
972    /// `SUCCESS`, `SUCCESS_WITH_INFO`, `ERROR`, or `INVALID_HANDLE`.
973    pub fn SQLSetDescFieldW(
974        hdesc: HDesc,
975        rec_number: SmallInt,
976        field_identifier: Desc,
977        value: Pointer,
978        buffer_length: Integer,
979    ) -> SqlReturn;
980
981    /// Used together with [`SQLPutData`] to supply parameter data at statement execution time, and
982    /// with [`SQLGetData`] to retrieve streamed output parameter data.
983    ///
984    /// # Returns
985    ///
986    /// `SUCCESS`, `SUCCESS_WITH_INFO`, `NEED_DATA`, `NO_DATA`, `STILL_EXECUTING`, `ERROR`,
987    /// `INVALID_HANDLE`, or `PARAM_DATA_AVAILABLE`.
988    pub fn SQLParamData(hstmt: HStmt, value_out: *mut Pointer) -> SqlReturn;
989}