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, Len, Lock, Nullability, Operation, ParamType, Pointer, RetCode,
5 SetPosIRow, SqlDataType, SqlReturn, StatementAttribute, ULen, 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: i32,
56 string_length: *mut i32,
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: i32,
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: i16,
86 state: *mut Char,
87 native_error_ptr: *mut i32,
88 message_text: *mut Char,
89 buffer_length: i16,
90 text_length_ptr: *mut i16,
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: i16,
103 state: *mut WChar,
104 native_error_ptr: *mut i32,
105 message_text: *mut WChar,
106 buffer_length: i16,
107 text_length_ptr: *mut i16,
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: i16,
120 diag_identifier: i16,
121 diag_info_ptr: Pointer,
122 buffer_length: i16,
123 string_length_ptr: *mut i16,
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: i32,
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: i32,
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 i16) -> 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 i16) -> 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: u16,
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: i16,
208 string_length_ptr: *mut i16,
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: i16,
220 string_length_ptr: *mut i16,
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: i16,
234 user_name: *const WChar,
235 name_length_2: i16,
236 authentication: *const WChar,
237 name_length_3: i16,
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: i16,
251 user_name: *const Char,
252 name_length_2: i16,
253 authentication: *const Char,
254 name_length_3: i16,
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: i16,
267 schema_name: *const Char,
268 name_length_2: i16,
269 table_name: *const Char,
270 name_length_3: i16,
271 table_type: *const Char,
272 name_length_4: i16,
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: i16,
285 schema_name: *const WChar,
286 name_length_2: i16,
287 table_name: *const WChar,
288 name_length_3: i16,
289 table_type: *const WChar,
290 name_length_4: i16,
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: i16,
303 name_length_1: *mut i16,
304 description: *mut Char,
305 buffer_length_2: i16,
306 name_length_2: *mut i16,
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: i16,
319 name_length_1: *mut i16,
320 description: *mut WChar,
321 buffer_length_2: i16,
322 name_length_2: *mut i16,
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: i16,
337 out_connection_string: *mut Char,
338 buffer_length: i16,
339 string_length_2: *mut i16,
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: i16,
355 out_connection_string: *mut WChar,
356 buffer_length: i16,
357 string_length_2: *mut i16,
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: i16,
371 out_driver_desc: *mut i16,
372 driver_attributes: *mut Char,
373 drvr_attr_max: i16,
374 out_drvr_attr: *mut i16,
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: i16,
387 out_driver_desc: *mut i16,
388 driver_attributes: *mut WChar,
389 drvr_attr_max: i16,
390 out_drvr_attr: *mut i16,
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: u16,
406 input_output_type: ParamType,
407 value_type: CDataType,
408 parameter_type: SqlDataType,
409 column_size: ULen,
410 decimal_digits: i16,
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: i32) -> SqlReturn;
440
441 /// Compiles the statement and generates an access plan.
442 ///
443 /// # Returns
444 /// `SUCCESS`, `SUCCESS_WITH_INFO`, `ERROR`, `INVALID_HANDLE`, or
445 /// `SQL_STILL_EXECUTING`
446 pub fn SQLPrepareW(hstmt: HStmt, statement_text: *const WChar, text_length: i32) -> SqlReturn;
447
448 /// Executes a prepared statement, using the current values of the parameter marker variables
449 /// if any paramater markers exis in the statement.
450 ///
451 /// # Returns
452 /// `SUCCESS`, `SUCCESS_WITH_INFO`, `SQL_NEED_DATA`, `SQL_STILL_EXECUTING`, `ERROR`
453 /// , `SQL_NO_DATA`, `INVALID_HANDLE`, or `SQL_PARAM_DATA_AVAILABLE`.
454 pub fn SQLExecute(hstmt: HStmt) -> SqlReturn;
455
456 /// Stops processing associated with a specific statement, closes any open cursors associated
457 /// with the statement, discards pending results, or, optionally, frees all resources
458 /// associated with the statement handle.
459 ///
460 /// # Returns
461 /// `SUCCESS`, `SUCCESS_WITH_INFO`, `ERROR`, or `INVALID_HANDLE`.
462 pub fn SQLFreeStmt(hstmt: HStmt, option: FreeStmtOption) -> SqlReturn;
463
464 /// Binds application data bufferst to columns in the result set.
465 ///
466 /// # Returns
467 /// `SUCCESS`, `SUCCESS_WITH_INFO`, `ERROR`, or `INVALID_HANDLE`.
468 pub fn SQLBindCol(
469 hstmt: HStmt,
470 col_number: u16,
471 target_type: CDataType,
472 target_value: Pointer,
473 buffer_length: Len,
474 length_or_indicator: *mut Len,
475 ) -> SqlReturn;
476
477 /// SQLBrowseConnect supports an iterative method of discovering and enumerating the attributes
478 /// and attribute values required to connect to a data source.
479 /// Each call to SQLBrowseConnect returns successive levels of attributes and attribute values.
480 ///
481 /// # Returns
482 /// `SUCCESS`, `SUCCESS_WITH_INFO`, `SQL_NEED_DATA`, `ERROR`, `INVALID_HANDLE`, or `SQL_STILL_EXECUTING`.
483 pub fn SQLBrowseConnectW(
484 connection_handle: HDbc,
485 in_connection_string: *const WChar,
486 string_length: i16,
487 out_connection_string: *mut WChar,
488 buffer_length: i16,
489 out_buffer_length: *mut i16,
490 ) -> SqlReturn;
491
492 /// Returns descriptor information for a column in a result set. Descriptor information is
493 /// returned as a character string, a descriptor-dependent value, or an integer value.
494 ///
495 /// # Returns
496 /// `SUCCESS`, `SUCCESS_WITH_INFO`, `ERROR`, `INVALID_HANDLE`, or `SQL_STILL_EXECUTING`.
497 pub fn SQLColAttributeW(
498 statement_handle: HStmt,
499 column_number: u16,
500 field_identifier: Desc,
501 character_attribute_ptr: Pointer,
502 buffer_length: i16,
503 string_length_ptr: *mut i16,
504 numeric_attribute_ptr: *mut Len,
505 ) -> SqlReturn;
506
507 /// Returns descriptor information for a column in a result set. Descriptor information is
508 /// returned as a character string, a descriptor-dependent value, or an integer value.
509 ///
510 /// # Returns
511 /// `SUCCESS`, `SUCCESS_WITH_INFO`, `ERROR`, `INVALID_HANDLE`, or `SQL_STILL_EXECUTING`.
512 pub fn SQLColAttribute(
513 statement_handle: HStmt,
514 column_number: u16,
515 field_identifier: Desc,
516 character_attribute_ptr: Pointer,
517 buffer_length: i16,
518 string_length_ptr: *mut i16,
519 numeric_attribute_ptr: *mut Len,
520 ) -> SqlReturn;
521
522 /// Copies descriptor information from one descriptor handle to another.
523 ///
524 /// # Returns
525 /// `SUCCESS`, `ERROR`, `SQL_NO_DATA`, or `INVALID_HANDLE`.
526 pub fn SQLCopyDesc(source_desc_handle: HDesc, target_desc_handle: HDesc) -> SqlReturn;
527
528 /// Returns the current setting of a connection attribute.
529 ///
530 /// * `buffer_length`: is either buffer length or one of [`crate::IS_POINTER`],
531 /// [`crate::IS_UINTEGER`], [`crate::IS_INTEGER`], [`crate::IS_USMALLINT`] or
532 /// [`crate::IS_SMALLINT`].
533 ///
534 /// # Returns
535 /// `SUCCESS`, `ERROR`, `SQL_NO_DATA`, or `INVALID_HANDLE`.
536 pub fn SQLGetConnectAttr(
537 connection_handle: HDbc,
538 attribute: ConnectionAttribute,
539 value_ptr: Pointer,
540 buffer_length: i32,
541 string_length_ptr: *mut i32,
542 ) -> SqlReturn;
543
544 /// Returns the current setting of a connection attribute.
545 ///
546 /// * `buffer_length`: is either buffer length or one of [`crate::IS_POINTER`],
547 /// [`crate::IS_UINTEGER`], [`crate::IS_INTEGER`], [`crate::IS_USMALLINT`] or
548 /// [`crate::IS_SMALLINT`].
549 ///
550 /// # Returns
551 /// `SUCCESS`, `ERROR`, `SQL_NO_DATA`, or `INVALID_HANDLE`.
552 pub fn SQLGetConnectAttrW(
553 connection_handle: HDbc,
554 attribute: ConnectionAttribute,
555 value_ptr: Pointer,
556 buffer_length: i32,
557 string_length_ptr: *mut i32,
558 ) -> SqlReturn;
559
560 /// Returns the cursor name associated with a specified statement.
561 ///
562 /// # Returns
563 /// `SUCCESS`, `SUCCESS_WITH_INFO`, `ERROR`, or `INVALID_HANDLE`.
564 pub fn SQLGetCursorNameW(
565 statement_handle: HStmt,
566 cursor_name: *mut WChar,
567 buffer_length: i16,
568 name_length_ptr: *mut i16,
569 ) -> SqlReturn;
570
571 /// Returns the current setting or value of a single field of a descriptor record.
572 ///
573 /// # Returns
574 /// `SUCCESS`, `SUCCESS_WITH_INFO`, `ERROR`, `SQL_NO_DATA`, or `INVALID_HANDLE`.
575 /// `SQL_NO_DATA` is returned if RecNumber is greater than the current number of descriptor records.
576 /// `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.
577 pub fn SQLGetDescFieldW(
578 descriptor_handle: HDesc,
579 record_number: i16,
580 field_identifier: Desc,
581 value_ptr: Pointer,
582 buffer_length: i32,
583 string_length_ptr: *mut i32,
584 ) -> SqlReturn;
585
586 /// Returns the current settings or values of multiple fields of a descriptor record.
587 /// The fields returned describe the name, data type, and storage of column or parameter data.
588 ///
589 /// # Returns
590 /// `SUCCESS`, `SUCCESS_WITH_INFO`, `ERROR`, `SQL_NO_DATA`, or `INVALID_HANDLE`.
591 /// `SQL_NO_DATA` is returned if RecNumber is greater than the current number of descriptor records.
592 /// `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.
593 pub fn SQLGetDescRecW(
594 descriptor_handle: HDesc,
595 record_number: i16,
596 name: *mut WChar,
597 buffer_length: i16,
598 string_length_ptr: *mut i16,
599 type_ptr: *mut i16,
600 sub_type_ptr: *mut i16,
601 length_ptr: *mut Len,
602 precision_ptr: *mut i16,
603 scale_ptr: *mut i16,
604 nullable_ptr: *mut Nullability,
605 ) -> SqlReturn;
606
607 /// Returns a list of columns and associated privileges for the specified table.
608 /// The driver returns the information as a result set on the specified StatementHandle.
609 ///
610 /// # Returns
611 /// `SUCCESS`, `SUCCESS_WITH_INFO`, `ERROR`, `INVALID_HANDLE`, or `SQL_STILL_EXECUTING`.
612 pub fn SQLColumnPrivilegesW(
613 statement_handle: HStmt,
614 catalog_name: *const WChar,
615 catalog_name_length: i16,
616 schema_name: *const WChar,
617 schema_name_length: i16,
618 table_name: *const WChar,
619 table_name_length: i16,
620 column_name: *const WChar,
621 column_name_length: i16,
622 ) -> SqlReturn;
623
624 /// Returns the list of column names in specified tables. The driver returns this information as
625 /// a result set on the specified StatementHandle.
626 ///
627 /// # Returns
628 /// `SUCCESS`, `SUCCESS_WITH_INFO`, `ERROR`, `INVALID_HANDLE`, or `SQL_STILL_EXECUTING`.
629 pub fn SQLColumns(
630 statement_handle: HStmt,
631 catalog_name: *const Char,
632 catalog_name_length: i16,
633 schema_name: *const Char,
634 schema_name_length: i16,
635 table_name: *const Char,
636 table_name_length: i16,
637 column_name: *const Char,
638 column_name_length: i16,
639 ) -> SqlReturn;
640
641 /// Returns the list of column names in specified tables. The driver returns this information as
642 /// a result set on the specified StatementHandle.
643 ///
644 /// # Returns
645 /// `SUCCESS`, `SUCCESS_WITH_INFO`, `ERROR`, `INVALID_HANDLE`, or `SQL_STILL_EXECUTING`.
646 pub fn SQLColumnsW(
647 statement_handle: HStmt,
648 catalog_name: *const WChar,
649 catalog_name_length: i16,
650 schema_name: *const WChar,
651 schema_name_length: i16,
652 table_name: *const WChar,
653 table_name_length: i16,
654 column_name: *const WChar,
655 column_name_length: i16,
656 ) -> SqlReturn;
657
658 /// Create a result set which contains the column names that make up the primary key for the
659 /// table.
660 ///
661 /// # Parameters
662 ///
663 /// * `hstmt`: Statement Handle
664 /// * `catalog_name`: Catalog name. If a driver supports catalogs for some tables but not for
665 /// others, such as when the driver retrieves data from different DBMSs, an empty string ("")
666 /// denotes those tables that do not have catalogs. `catalog_name` cannot contain a string
667 /// search pattern.
668 /// * `catalog_name_length`: Length of `catalog_name` in characters.
669 /// * `schema_name`: Schema name. If a driver supports schemas for some tables but not for
670 /// others, such as when the driver retrieves data from different DBMSs, an empty string ("")
671 /// denotes those tables that do not have schemas. `schema_name` cannot contain a string
672 /// search pattern.
673 /// * `schema_name_length`: Length of `schema_name` in characters.
674 /// * `table_name`: Table name. This argument can not be a null pointer. `table_name` cannot
675 /// contain a string search pattern.
676 ///
677 /// If [`StatementAttribute::MetadataId`] statement attribute is set to true, catalog, schema
678 /// and table name parameters are treated as an identifiers and their case is not significant.
679 /// If it is false, they are ordinary arguments. As such they treated literally and their case
680 /// is significant.
681 ///
682 /// See: <https://learn.microsoft.com/sql/odbc/reference/syntax/sqlprimarykeys-function>
683 ///
684 /// # Returns
685 ///
686 /// `SUCCESS`, `SUCCESS_WITH_INFO`, `STILL_EXECUTING`, `ERROR`, or `INVALID_HANDLE`.
687 pub fn SQLPrimaryKeys(
688 hstmt: HStmt,
689 catalog_name: *const Char,
690 catalog_name_length: i16,
691 schema_name: *const Char,
692 schema_name_length: i16,
693 table_name: *const Char,
694 table_name_length: i16,
695 ) -> SqlReturn;
696
697 /// Create a result set which contains the column names that make up the primary key for the
698 /// table.
699 ///
700 /// # Parameters
701 ///
702 /// * `hstmt`: Statement Handle
703 /// * `catalog_name`: Catalog name. If a driver supports catalogs for some tables but not for
704 /// others, such as when the driver retrieves data from different DBMSs, an empty string ("")
705 /// denotes those tables that do not have catalogs. `catalog_name` cannot contain a string
706 /// search pattern.
707 /// * `catalog_name_length`: Length of `catalog_name` in characters.
708 /// * `schema_name`: Schema name. If a driver supports schemas for some tables but not for
709 /// others, such as when the driver retrieves data from different DBMSs, an empty string ("")
710 /// denotes those tables that do not have schemas. `schema_name` cannot contain a string
711 /// search pattern.
712 /// * `schema_name_length`: Length of `schema_name` in characters.
713 /// * `table_name`: Table name. This argument can not be a null pointer. `table_name` cannot
714 /// contain a string search pattern.
715 ///
716 /// If [`StatementAttribute::MetadataId`] statement attribute is set to true, catalog, schema
717 /// and table name parameters are treated as an identifiers and their case is not significant.
718 /// If it is false, they are ordinary arguments. As such they treated literally and their case
719 /// is significant.
720 ///
721 /// See: <https://learn.microsoft.com/sql/odbc/reference/syntax/sqlprimarykeys-function>
722 ///
723 /// # Returns
724 ///
725 /// `SUCCESS`, `SUCCESS_WITH_INFO`, `STILL_EXECUTING`, `ERROR`, or `INVALID_HANDLE`.
726 pub fn SQLPrimaryKeysW(
727 hstmt: HStmt,
728 catalog_name: *const WChar,
729 catalog_name_length: i16,
730 schema_name: *const WChar,
731 schema_name_length: i16,
732 table_name: *const WChar,
733 table_name_length: i16,
734 ) -> SqlReturn;
735
736 /// Can be used to determine when an asynchronous function is complete using either notification- or polling-based processing.
737 ///
738 /// # Returns
739 /// `SUCCESS`, `ERROR`, `SQL_NO_DATA`, or `INVALID_HANDLE`.
740 #[cfg(feature = "odbc_version_3_80")]
741 pub fn SQLCompleteAsync(
742 handle_type: HandleType,
743 handle: Handle,
744 async_ret_code_ptr: *mut RetCode,
745 ) -> SqlReturn;
746
747 /// Returns the current setting of a statement attribute.
748 ///
749 /// A call to `SQLGetStmtAttr` returns in `value` the value of the statement attribute specified
750 /// in `attribute`. That value can either be a `ULen` value or a null-terminated character
751 /// string. If the value is a `ULen` value, some drivers may only write the lower 32-bit or
752 /// 16-bit of a buffer and leave the higher-order bit unchanged. Therefore, applications should
753 /// use a buffer of `ULen and initialize the value to 0 before calling this function. Also, the
754 /// `buffer_length` and `string_length` arguments are not used. If the value is a
755 /// null-terminated string, the application specifies the maximum length of that string in the
756 /// `buffer_length` argument, and the driver returns the length of that string in the
757 /// `string_length` buffer.
758 ///
759 /// To allow applications calling `SQLGetStmtAttr` to work with ODBC 2.x drivers, a call to
760 /// `SQLGetStmtAttr` is mapped in the Driver Manager to SQLGetStmtOption.
761 /// The following statement attributes are read-only, so can be retrieved by `SQLGetStmtAttr`,
762 /// but not set by SQLSetStmtAttr:
763 ///
764 /// * `StatementAttribute::ImpParamDesc`
765 /// * `StatementAttribute::ImpRowDesc`
766 /// * `StatementAttribute::RowNumber`
767 ///
768 /// # Returns
769 ///
770 /// `SUCCESS`, `SUCCESS_WITH_INFO`, `ERROR`, or `INVALID_HANDLE`.
771 pub fn SQLGetStmtAttr(
772 hstmt: HStmt,
773 attribute: StatementAttribute,
774 value: Pointer,
775 buffer_length: i32,
776 string_length: *mut i32,
777 ) -> SqlReturn;
778
779 /// Returns the current setting of a statement attribute.
780 ///
781 /// A call to `SQLGetStmtAttr` returns in `value` the value of the statement attribute specified
782 /// in `attribute`. That value can either be a `ULen` value or a null-terminated character
783 /// string. If the value is a `ULen` value, some drivers may only write the lower 32-bit or
784 /// 16-bit of a buffer and leave the higher-order bit unchanged. Therefore, applications should
785 /// use a buffer of `ULen and initialize the value to 0 before calling this function. Also, the
786 /// `buffer_length` and `string_length` arguments are not used. If the value is a
787 /// null-terminated string, the application specifies the maximum length of that string in the
788 /// `buffer_length` argument, and the driver returns the length of that string in the
789 /// `string_length` buffer.
790 ///
791 /// To allow applications calling `SQLGetStmtAttr` to work with ODBC 2.x drivers, a call to
792 /// `SQLGetStmtAttr` is mapped in the Driver Manager to SQLGetStmtOption.
793 /// The following statement attributes are read-only, so can be retrieved by `SQLGetStmtAttr`,
794 /// but not set by SQLSetStmtAttr:
795 ///
796 /// * `StatementAttribute::ImpParamDesc`
797 /// * `StatementAttribute::ImpRowDesc`
798 /// * `StatementAttribute::RowNumber`
799 ///
800 /// # Returns
801 ///
802 /// `SUCCESS`, `SUCCESS_WITH_INFO`, `ERROR`, or `INVALID_HANDLE`.
803 pub fn SQLGetStmtAttrW(
804 handle: HStmt,
805 attribute: StatementAttribute,
806 value_ptr: Pointer,
807 buffer_length: i32,
808 string_length_ptr: *mut i32,
809 ) -> SqlReturn;
810
811 /// Fetches the specified rowset of data from the result set and returns data for all bound columns.
812 /// Rowsets can be specified at an absolute or relative position or by bookmark.
813 ///
814 /// # Returns
815 ///
816 /// `SUCCESS`, `SUCCESS_WITH_INFO`, `ERROR`, `INVALID_HANDLE`, or `STILL_EXECUTING`.
817 pub fn SQLFetchScroll(
818 statement_handle: HStmt,
819 fetch_orientation: FetchOrientation,
820 fetch_offset: Len,
821 ) -> SqlReturn;
822
823 /// Sets the cursor position in a rowset and allows an application to refresh, update or delete
824 /// data in the rowset.
825 ///
826 /// See: <https://learn.microsoft.com/sql/odbc/reference/syntax/sqlsetpos-function>
827 ///
828 /// # Parameters
829 ///
830 /// * `statement_handle`: Statement Handle
831 /// * `row_number`: Position of the row in the rowset on which to perform the operation
832 /// specified with the Operation argument. If `row_number` is 0, the operation applies to
833 /// every row in the rowset.
834 /// * `operation`: Operation to perform
835 /// * `lock_type`: Specifies how to lock the row after performing the operation specified in the
836 /// Operation argument.
837 ///
838 /// # Returns
839 ///
840 /// `SUCCESS`, `SUCCESS_WITH_INFO`, `NEED_DATA`, `STILL_EXECUTING`, `ERROR`, or
841 /// `INVALID_HANDLE`.
842 pub fn SQLSetPos(
843 statement_handle: HStmt,
844 row_number: SetPosIRow,
845 operation: Operation,
846 lock_type: Lock,
847 ) -> SqlReturn;
848
849 /// Can return:
850 /// - A list of foreign keys in the specified table (columns in the specified table that refer to primary keys in other tables).
851 /// - A list of foreign keys in other tables that refer to the primary key in the specified table.
852 ///
853 /// The driver returns each list as a result set on the specified statement.
854 ///
855 /// # Returns
856 /// `SUCCESS`, `SUCCESS_WITH_INFO`, `ERROR`, `INVALID_HANDLE`, or `SQL_STILL_EXECUTING`.
857 pub fn SQLForeignKeys(
858 statement_handle: HStmt,
859 pk_catalog_name: *const Char,
860 pk_catalog_name_length: i16,
861 pk_schema_name: *const Char,
862 pk_schema_name_length: i16,
863 pk_table_name: *const Char,
864 pk_table_name_length: i16,
865 fk_catalog_name: *const Char,
866 fk_catalog_name_length: i16,
867 fk_schema_name: *const Char,
868 fk_schema_name_length: i16,
869 fk_table_name: *const Char,
870 fk_table_name_length: i16,
871 ) -> SqlReturn;
872
873 /// Can return:
874 /// - A list of foreign keys in the specified table (columns in the specified table that refer to primary keys in other tables).
875 /// - A list of foreign keys in other tables that refer to the primary key in the specified table.
876 ///
877 /// The driver returns each list as a result set on the specified statement.
878 ///
879 /// # Returns
880 /// `SUCCESS`, `SUCCESS_WITH_INFO`, `ERROR`, `INVALID_HANDLE`, or `SQL_STILL_EXECUTING`.
881 pub fn SQLForeignKeysW(
882 statement_handle: HStmt,
883 pk_catalog_name: *const WChar,
884 pk_catalog_name_length: i16,
885 pk_schema_name: *const WChar,
886 pk_schema_name_length: i16,
887 pk_table_name: *const WChar,
888 pk_table_name_length: i16,
889 fk_catalog_name: *const WChar,
890 fk_catalog_name_length: i16,
891 fk_schema_name: *const WChar,
892 fk_schema_name_length: i16,
893 fk_table_name: *const WChar,
894 fk_table_name_length: i16,
895 ) -> SqlReturn;
896
897 /// Returns the result descriptor for one column in the result set — column name, type, column
898 /// size, decimal digits, and nullability.
899 ///
900 /// This information also is available in the fields of the IRD.
901 ///
902 /// # Returns
903 /// `SUCCESS`, `SUCCESS_WITH_INFO`, `SQL_STILL_EXECUTING`, `ERROR`, or
904 /// `INVALID_HANDLE`.
905 pub fn SQLDescribeCol(
906 hstmt: HStmt,
907 col_number: u16,
908 col_name: *mut Char,
909 buffer_length: i16,
910 name_length: *mut i16,
911 data_type: *mut SqlDataType,
912 col_size: *mut ULen,
913 decimal_digits: *mut i16,
914 nullable: *mut Nullability,
915 ) -> SqlReturn;
916
917 /// Returns the result descriptor for one column in the result set — column name, type, column
918 /// size, decimal digits, and nullability.
919 ///
920 /// This information also is available in the fields of the IRD.
921 ///
922 /// # Returns
923 /// `SUCCESS`, `SUCCESS_WITH_INFO`, `SQL_STILL_EXECUTING`, `ERROR`, or
924 /// `INVALID_HANDLE`.
925 pub fn SQLDescribeColW(
926 hstmt: HStmt,
927 col_number: u16,
928 col_name: *mut WChar,
929 buffer_length: i16,
930 name_length: *mut i16,
931 data_type: *mut SqlDataType,
932 col_size: *mut ULen,
933 decimal_digits: *mut i16,
934 nullable: *mut Nullability,
935 ) -> SqlReturn;
936
937 /// Returns the description of a parameter marker associated with a prepared SQL statement.
938 /// This information is also available in the fields of the IPD.
939 ///
940 /// # Returns
941 ///
942 /// `SUCCESS`, `SUCCESS_WITH_INFO`, `SQL_STILL_EXECUTING`, `ERROR`, or
943 /// `INVALID_HANDLE`.
944 pub fn SQLDescribeParam(
945 statement_handle: HStmt,
946 parameter_number: u16,
947 data_type_ptr: *mut SqlDataType,
948 parameter_size_ptr: *mut ULen,
949 decimal_digits_ptr: *mut i16,
950 nullable_ptr: *mut Nullability,
951 ) -> SqlReturn;
952
953 /// Sets attributes related to a statement.
954 ///
955 /// # Returns
956 /// `SUCCESS`, `SUCCESS_WITH_INFO`, `ERROR`, or `INVALID_HANDLE`.
957 pub fn SQLSetStmtAttr(
958 hstmt: HStmt,
959 attr: StatementAttribute,
960 value: Pointer,
961 str_length: i32,
962 ) -> SqlReturn;
963
964 /// Sets attributes related to a statement.
965 ///
966 /// # Returns
967 /// `SUCCESS`, `SUCCESS_WITH_INFO`, `ERROR`, or `INVALID_HANDLE`.
968 pub fn SQLSetStmtAttrW(
969 hstmt: HStmt,
970 attr: StatementAttribute,
971 value: Pointer,
972 str_length: i32,
973 ) -> SqlReturn;
974
975 /// Sets attributes that govern aspects of connections.
976 ///
977 /// # Returns
978 /// `SUCCESS`, `SUCCESS_WITH_INFO`, `ERROR`, `INVALID_HANDLE`, or `SQL_STILL_EXECUTING`.
979 pub fn SQLSetConnectAttr(
980 hdbc: HDbc,
981 attr: ConnectionAttribute,
982 value: Pointer,
983 str_length: i32,
984 ) -> SqlReturn;
985
986 /// Sets attributes that govern aspects of connections.
987 ///
988 /// # Returns
989 ///
990 /// `SUCCESS`, `SUCCESS_WITH_INFO`, `ERROR`, `INVALID_HANDLE`, or `SQL_STILL_EXECUTING`.
991 pub fn SQLSetConnectAttrW(
992 hdbc: HDbc,
993 attr: ConnectionAttribute,
994 value: Pointer,
995 str_length: i32,
996 ) -> SqlReturn;
997
998 /// Requests a commit or rollback operation for all active operations on all statements associated with a handle.
999 ///
1000 /// # Returns
1001 ///
1002 /// `SUCCESS`, `SUCCESS_WITH_INFO`, `ERROR`, `INVALID_HANDLE`, or `SQL_STILL_EXECUTING`.
1003 pub fn SQLEndTran(
1004 handle_type: HandleType,
1005 handle: Handle,
1006 completion_type: CompletionType,
1007 ) -> SqlReturn;
1008
1009 /// Returns the number of rows affected by an UPDATE, INSERT, or DELETE statement; an `SQL_ADD`,
1010 /// `SQL_UPDATE_BY_BOOKMARK`, or `SQL_DELETE_BY_BOOKMARK` operation in SQLBulkOperations; or an
1011 /// `SQL_UPDATE` or `SQL_DELETE` operation in `SQLSetPos`.
1012 ///
1013 /// # Returns
1014 /// `SUCCESS`, `SUCCESS_WITH_INFO`, `INVALID_HANDLE`, or `ERROR`.
1015 pub fn SQLRowCount(hstmt: HStmt, row_count: *mut Len) -> SqlReturn;
1016
1017 /// Allows an application to send data for a parameter or column to the driver at statement
1018 /// execution time. This function can be used to send character or binary data values in parts
1019 /// to a column with a character, binary, or data source-specific data type (for example,
1020 /// parameters of the SQL_LONGVARBINARY or SQL_LONGVARCHAR types). SQLPutData supports binding
1021 /// to a Unicode C data type, even if the underlying driver does not support Unicode data.
1022 ///
1023 /// # Returns
1024 ///
1025 /// `SUCCESS`, `SUCCESS_WITH_INFO`, `STILL_EXECUTING`, `ERROR`, or `INVALID_HANDLE`.
1026 pub fn SQLPutData(hstmt: HStmt, data: Pointer, str_len_or_ind: Len) -> SqlReturn;
1027
1028 /// Sets the value of a single field of a descriptor record.
1029 ///
1030 /// # Returns
1031 ///
1032 /// `SUCCESS`, `SUCCESS_WITH_INFO`, `ERROR`, or `INVALID_HANDLE`.
1033 pub fn SQLSetDescField(
1034 hdesc: HDesc,
1035 rec_number: i16,
1036 field_identifier: Desc,
1037 value: Pointer,
1038 buffer_length: i32,
1039 ) -> SqlReturn;
1040
1041 /// Sets the value of a single field of a descriptor record.
1042 ///
1043 /// # Returns
1044 ///
1045 /// `SUCCESS`, `SUCCESS_WITH_INFO`, `ERROR`, or `INVALID_HANDLE`.
1046 pub fn SQLSetDescFieldW(
1047 hdesc: HDesc,
1048 rec_number: i16,
1049 field_identifier: Desc,
1050 value: Pointer,
1051 buffer_length: i32,
1052 ) -> SqlReturn;
1053
1054 /// Used together with [`SQLPutData`] to supply parameter data at statement execution time, and
1055 /// with [`SQLGetData`] to retrieve streamed output parameter data.
1056 ///
1057 /// # Returns
1058 ///
1059 /// `SUCCESS`, `SUCCESS_WITH_INFO`, `NEED_DATA`, `NO_DATA`, `STILL_EXECUTING`, `ERROR`,
1060 /// `INVALID_HANDLE`, or `PARAM_DATA_AVAILABLE`.
1061 pub fn SQLParamData(hstmt: HStmt, value_out: *mut Pointer) -> SqlReturn;
1062}