├── LICENSE
├── README.md
├── binding.gyp
├── build.js
├── examples
├── app1.js
└── readme.txt
├── lib
└── index.js
├── package.json
└── src
├── h
├── connection.h
├── errors.h
├── nodever_cover.h
├── sacapi.h
├── sacapidll.h
├── sqlany_utils.h
└── stmt.h
├── sacapidll.cpp
├── sqlanywhere.cpp
└── utils.cpp
/LICENSE:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
177 |
178 | APPENDIX: How to apply the Apache License to your work.
179 |
180 | To apply the Apache License to your work, attach the following
181 | boilerplate notice, with the fields enclosed by brackets "{}"
182 | replaced with your own identifying information. (Don't include
183 | the brackets!) The text should be enclosed in the appropriate
184 | comment syntax for the file format. We also recommend that a
185 | file or class name and description of purpose be included on the
186 | same "printed page" as the copyright notice for easier
187 | identification within third-party archives.
188 |
189 | Copyright {yyyy} {name of copyright owner}
190 |
191 | Licensed under the Apache License, Version 2.0 (the "License");
192 | you may not use this file except in compliance with the License.
193 | You may obtain a copy of the License at
194 |
195 | http://www.apache.org/licenses/LICENSE-2.0
196 |
197 | Unless required by applicable law or agreed to in writing, software
198 | distributed under the License is distributed on an "AS IS" BASIS,
199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200 | See the License for the specific language governing permissions and
201 | limitations under the License.
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # node-sqlanywhere
2 | This is a Node.js driver written for [SAP SQL Anywhere](https://www.sap.com/products/sql-anywhere.html).
3 |
4 | [](https://nodei.co/npm/sqlanywhere/)
5 |
6 | ## Install
7 | ```
8 | npm install sqlanywhere
9 | ```
10 | #### Prerequisites
11 | This driver communicates with the native SQL Anywhere libraries, and thus requires
12 | native compilation. Native compilation is managed by [`node-gyp`](https://github.com/TooTallNate/node-gyp/). Please see that project for additional prerequisites including Python and a C/C++ tool chain.
13 |
14 | The official version hosted on NPM includes precompiled libraries for Windows (64-bit).
15 |
16 | Versions supported:
17 |
18 |
19 |
Driver version
Node.js version
20 |
1.0.6
0.10, 0.12, 4.x, 5.x
21 |
1.0.9
6.x, 7.x
22 |
1.0.19
8.x
23 |
1.0.22
9.x
24 |
1.0.23
10.x
25 |
1.0.24
Only 5.x through 10.x (support for 0.10, 0.12, and 4.x is dropped)
26 |
1.0.25
5.x through 12.x
27 |
1.0.26
6.x through 12.x
28 |
1.0.27
6.x through 12.x
29 |
30 |
31 | ## Getting Started
32 |
33 | ```js
34 | var sqlanywhere = require('sqlanywhere');
35 |
36 | var conn = sqlanywhere.createConnection();
37 |
38 | var conn_params = {
39 | Server : 'demo16',
40 | UserId : 'DBA',
41 | Password: 'sql'
42 | };
43 |
44 |
45 | conn.connect(conn_params, function(err) {
46 | if (err) throw err;
47 | conn.exec('SELECT Name, Description FROM Products WHERE id = ?', [301], function (err, result) {
48 | if (err) throw err;
49 |
50 | console.log('Name: ', result[0].Name, ', Description: ', result[0].Description);
51 | // output --> Name: Tee Shirt, Description: V-neck
52 | conn.disconnect();
53 | })
54 | });
55 | ```
56 |
57 | ## Establish a database connection
58 | ### Connecting
59 | A database connection object is created by calling `createConnection`. The connection is established by calling the connection object's `connect` method, and passing in an object representing connection parameters. The object can contain most valid [connection properties](http://dcx.sybase.com/index.html#sa160/en/dbadmin/da-conparm.html).
60 |
61 | ##### Example: Connecting over TCP/IP
62 | ```js
63 | conn.connect({
64 | Host : 'localhost:2638'
65 | UserId : 'DBA',
66 | Password: 'sql'
67 | });
68 | ```
69 |
70 | ##### Example: Auto-starting a database on first connection
71 | ```js
72 | conn.connect({
73 | DatabaseFile: 'demo.db',
74 | AutoStart: 'YES',
75 | UserId: 'DBA',
76 | Password: 'sql',
77 | });
78 | ```
79 |
80 | ### Disconnecting
81 |
82 | The `disconnect()` function closes the connection. As of version 1.0.16, you can also use `close()`.
83 |
84 | ```js
85 | conn.disconnect(function(err) {
86 | if (err) throw err;
87 | console.log('Disconnected');
88 | });
89 | ```
90 |
91 | ### Determining whether you are connected
92 | The connected() method was added in version 1.0.16.
93 | ```js
94 | var conn = sqlanywhere.createConnection();
95 | var connected = conn.connected(); // connected === false
96 | conn.connect({ ... } );
97 | connected = conn.connected(); // connected === true
98 | conn.disconnect();
99 | connected = conn.connected(); // connected === false
100 | ```
101 |
102 | ## Direct Statement Execution
103 | Direct statement execution is the simplest way to execute SQL statements. The inputs are the SQL command to be executed, and an optional array of positional arguments. The result is returned using callbacks. The type of returned result depends on the kind of statement.
104 |
105 | #### DDL Statement
106 |
107 | In the case of a successful DDL Statement nothing is returned.
108 |
109 | ```js
110 | conn.exec('CREATE TABLE Test (id INTEGER PRIMARY KEY DEFAULT AUTOINCREMENT, msg LONG VARCHAR)', function (err, result) {
111 | if (err) throw err;
112 | console.log('Table Test created!');
113 | });
114 | ```
115 |
116 | #### DML Statement
117 |
118 | In the case of a DML Statement the number of `affectedRows` is returned.
119 |
120 | ```js
121 | conn.exec("INSERT INTO Test(msg) SELECT 'Hello,' || row_num FROM sa_rowgenerator(1, 10)", function (err, affectedRows) {
122 | if (err) throw err;
123 | console.log('Number of affected rows:', affectedRows);
124 | conn.commit();
125 | });
126 | ```
127 |
128 | #### Query
129 |
130 | The `exec` function is a convenient way to completely retrieve the result of a query. In this case all selected rows are fetched and returned in the callback.
131 |
132 | ```js
133 | conn.exec("SELECT * FROM Test WHERE id < 5", function (err, rows) {
134 | if (err) throw err;
135 | console.log('Rows:', rows);
136 | });
137 | ```
138 |
139 | Values in the query can be substitued with JavaScript variables by using `?` placeholders in the query, and passing an array of positional arguments.
140 |
141 | ```js
142 | conn.exec("SELECT * FROM Test WHERE id BETWEEN ? AND ?", [5, 8], function (err, rows) {
143 | if (err) throw err;
144 | console.log('Rows:', rows);
145 | });
146 | ```
147 |
148 | As of version 1.0.16, wide inserts, deletes, and updates are possible by passing in an array of arrays, one per row. For example, the following statement inserts three rows rather than just one:
149 |
150 | ```js
151 | conn.exec("INSERT INTO Test VALUES ( ?, ? )", [ [1, 10], [2, 20], [3, 30] ], function (err, rows) {
152 | if (err) throw err;
153 | console.log('Rows:', rows); // should display 3
154 | });
155 | ```
156 |
157 | When using wide statements, each array must have the same number of elements and the type of the values must be the same in each row.
158 |
159 | ## Prepared Statement Execution
160 | #### Prepare a Statement
161 | The connection returns a `statement` object which can be executed multiple times.
162 | ```js
163 | conn.prepare('SELECT * FROM Test WHERE id = ?', function (err, stmt){
164 | if (err) throw err;
165 | // do something with the statement
166 | });
167 | ```
168 |
169 | #### Execute a Statement
170 | The execution of a prepared statement is similar to the direct statement execution. The first parameter of `exec` function is an array with positional parameters. With version 1.0.16, wide statements (except SELECT) are supported here as well.
171 |
172 | ```js
173 | stmt.exec([16], function(err, rows) {
174 | if (err) throw err;
175 | console.log("Rows: ", rows);
176 | });
177 | ```
178 |
179 | #### Fetching multiple result sets
180 | As of version 1.0.16, you can prepare and execute a batch containing multiple select statements. To do this, you would prepare the multiple select statements and use `stmt.exec()` to fetch the first result set. To fetch the next result set, call `stmt.getMoreResults()`. getMoreResults takes an optional callback function (which takes the same arguments as `exec`), making it asynchronous. The `getMoreResults()` function returns `undefined` (or passes it to the callback function) after the last result set.
181 |
182 | A simple synchronous example is below.
183 | ```js
184 | stmt = conn.prepare( 'select 1 as a from dummy; select 2 as b, 3 as c from dummy' );
185 | rs = stmt.exec();
186 | // rs == [ { a: 1 } ]
187 | rs = stmt.getMoreResults();
188 | // rs = [ { b: 2, c: 3 } ]
189 | stmt.drop();
190 | ```
191 |
192 | #### Drop Statement
193 | ```js
194 | stmt.drop(function(err) {
195 | if (err) throw err;
196 | });
197 | ```
198 |
199 | ## Transaction Handling
200 | __Transactions are not automatically commited.__ Executing a statement implicitly starts a new transaction that must be explicitly committed, or rolled back.
201 |
202 | #### Commit a Transaction
203 |
204 | ```js
205 | conn.commit(function(err) {
206 | if (err) throw err;
207 | console.log('Transaction commited.');
208 | });
209 | ```
210 |
211 | #### Rollback a Transaction
212 | ```js
213 | conn.rollback(function(err) {
214 | if (err) throw err;
215 | console.log('Transaction rolled back.');
216 | });
217 | ```
218 |
219 | ## Resources
220 | + [SAP SQL Anywhere Documentation](http://dcx.sap.com/)
221 | + [SAP SQL Anywhere Developer Q&A Forum](http://sqlanywhere-forum.sap.com/)
222 |
--------------------------------------------------------------------------------
/binding.gyp:
--------------------------------------------------------------------------------
1 | {
2 | "targets": [
3 | {
4 | "target_name": "sqlanywhere",
5 | "defines": [ '_SACAPI_VERSION=5', 'DRIVER_NAME=sqlanywhere' ],
6 | "sources": [ "src/sqlanywhere.cpp",
7 | "src/utils.cpp",
8 | "src/sacapidll.cpp", ],
9 |
10 | "include_dirs": [
11 | "src/h",
12 | "=0.10"
12 | },
13 | "scripts": {
14 | "install": "node build.js"
15 | },
16 | "dependencies": {
17 | "help": "^3.0.2",
18 | "nan": "2.14.2"
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/src/h/connection.h:
--------------------------------------------------------------------------------
1 | // ***************************************************************************
2 | // Copyright (c) 2021 SAP SE or an SAP affiliate company. All rights reserved.
3 | // ***************************************************************************
4 | using namespace v8;
5 | using namespace node;
6 |
7 | #include "nodever_cover.h"
8 |
9 | /** Represents the connection to the database.
10 | * @class Connection
11 | *
12 | * The following example uses synchronous calls to create a new connection to
13 | * the database server, issue a SQL query against the server, display the
14 | * result set, and then disconnect from the server.
15 | *
16 | *
26 | *
27 | * The following example does essentially the same thing using callbacks
28 | * to perform asynchronous calls.
29 | * Error checking is included.
30 | *
31 | *
124 | *
125 | * You can also pass connection parameters into the createConnection function,
126 | * and those parameters are combined with those in the connect() function call
127 | * to get the connection string used for the connection. You can use a hash of
128 | * connection parameters or a connection string fragment in either call.
129 | *
130 | * var sqlanywhere = require( 'sqlanywhere' );
131 | * var client = sqlanywhere.createConnection( { uid: 'dba'; pwd: 'sql' } );
132 | * client.connect( 'server=MyServer;host=localhost' );
133 | * // the connection string that will be used is
134 | * // "uid=dba;pwd=sql;server=MyServer;host=localhost"
135 | *
136 | */
137 | class Connection : public ObjectWrap
138 | {
139 | public:
140 | /// @internal
141 | #if v010
142 | static void Init();
143 | #else
144 | static void Init( Isolate * );
145 | #endif
146 |
147 | /// @internal
148 | static NODE_API_FUNC( NewInstance );
149 |
150 | private:
151 | /// @internal
152 | #if v010
153 | Connection( const Arguments &args );
154 | #else
155 | Connection( const FunctionCallbackInfo &args );
156 | #endif
157 | /// @internal
158 | ~Connection();
159 |
160 | /// @internal
161 | static Persistent constructor;
162 |
163 | /// @internal
164 | static void noParamAfter( uv_work_t *req );
165 | /// @internal
166 | static void connectAfter( uv_work_t *req );
167 | /// @internal
168 | static void connectWork( uv_work_t *req );
169 | /// @internal
170 | static NODE_API_FUNC( New );
171 |
172 | /// Connect using an existing connection.
173 | //
174 | // This method connects to the database using an existing connection.
175 | // The DBCAPI connection handle obtained from the JavaScript External
176 | // environment needs to be passed in as a parameter. The disconnect
177 | // method should be called before the end of the program to free
178 | // up resources.
179 | //
180 | // @fn Connection::connect( Number DBCAPI_Handle, Function callback )
181 | //
182 | // @param DBCAPI_Handle The connection Handle ( type: Number )
183 | // @param callback The optional callback function. ( type: Function )
184 | //
185 | //
186 | // // In a method written for the JavaScript External Environment
187 | // var sqlanywhere = require( 'sqlanywhere' );
188 | // var client = sqlanywhere.createConnection;
189 | // client.connect( sa_dbcapi_handle, callback );
190 | //
191 | //
192 | // This method can be either synchronous or asynchronous depending on
193 | // whether or not a callback function is specified.
194 | // The callback function is of the form:
195 | //
196 | //
202 | //
203 | // @internal
204 | ///
205 |
206 | /** Creates a new connection.
207 | *
208 | * This method creates a new connection using either a connection string
209 | * or a hash of connection parameters passed in as a parameter. Before
210 | * the end of the program, the connection should be disconnected using
211 | * the disconnect method to free up resources.
212 | *
213 | * The CharSet (CS) connection parameter CS=UTF-8 is always appended
214 | * to the end of the connection string by the driver since it is
215 | * required that all strings are sent in that encoding.
216 | *
217 | * This method can be either synchronous or asynchronous depending on
218 | * whether or not a callback function is specified.
219 | * The callback function is of the form:
220 | *
221 | *
227 | *
228 | * The following synchronous example shows how to use the connect method.
229 | * It is not necessary to specify the CHARSET=UTF-8 connection parameter
230 | * since it is always added automatically.
231 | *
232 | *
237 | *
238 | * @fn Connection::connect( String conn_string, Function callback )
239 | *
240 | * @param conn_string A valid connection string ( type: String )
241 | * @param callback The optional callback function. ( type: Function )
242 | *
243 | * @see Connection::disconnect
244 | */
245 | static NODE_API_FUNC( connect );
246 |
247 | /** Closes the current connection.
248 | *
249 | * This method closes the current connection and should be
250 | * called before the program ends to free up resources.
251 | *
252 | * This method can be either synchronous or asynchronous depending on
253 | * whether or not a callback function is specified.
254 | * The callback function is of the form:
255 | *
256 | *
298 | *
299 | * For queries producing result sets, the result set object is returned
300 | * as the second parameter of the callback.
301 | * For insert, update and delete statements, the number of rows affected
302 | * is returned as the second parameter of the callback.
303 | * For other statements, result is undefined.
304 | *
305 | * The following synchronous example shows how to use the exec method.
306 | *
307 | *
308 | * var sqlanywhere = require( 'sqlanywhere' );
309 | * var client = sqlanywhere.createConnection();
310 | * client.connect( "ServerName=demo17;UID=DBA;PWD=sql" );
311 | * result = client.exec("SELECT * FROM Customers");
312 | * console.log( result );
313 | * client.disconnect()
314 | *
315 | *
316 | * The following synchronous example shows how to specify bind parameters.
317 | *
318 | *
319 | * var sqlanywhere = require( 'sqlanywhere' );
320 | * var client = sqlanywhere.createConnection();
321 | * client.connect( "ServerName=demo17;UID=DBA;PWD=sql" );
322 | * result = client.exec(
323 | * "SELECT * FROM Customers WHERE ID >=? AND ID ",
324 | * [300, 400] );
325 | * console.log( result );
326 | * client.disconnect()
327 | *
328 | *
329 | * @fn Result Connection::exec( String sql, Array params, Function callback )
330 | *
331 | * @param sql The SQL statement to be executed. ( type: String )
332 | * @param params Optional array of bind parameters. ( type: Array )
333 | * @param callback The optional callback function. ( type: Function )
334 | *
335 | * @return If no callback is specified, the result is returned.
336 | *
337 | */
338 | static NODE_API_FUNC( exec );
339 |
340 | /** Prepares the specified SQL statement.
341 | *
342 | * This method prepares a SQL statement and returns a Statement object
343 | * if successful.
344 | *
345 | * This method can be either synchronous or asynchronous depending on
346 | * whether or not a callback function is specified.
347 | * The callback function is of the form:
348 | *
349 | *
355 | *
356 | * The following synchronous example shows how to use the prepare method.
357 | *
358 | *
359 | * var sqlanywhere = require( 'sqlanywhere' );
360 | * var client = sqlanywhere.createConnection();
361 | * client.connect( "ServerName=demo17;UID=DBA;PWD=sql" )
362 | * stmt = client.prepare( "SELECT * FROM Customers WHERE ID >= ? AND ID < ?" );
363 | * result = stmt.exec( [200, 300] );
364 | * console.log( result );
365 | * client.disconnect();
366 | *
367 | *
368 | * @fn Statement Connection::prepare( String sql, Function callback )
369 | *
370 | * @param sql The SQL statement to be executed. ( type: String )
371 | * @param callback The optional callback function. ( type: Function )
372 | *
373 | * @return If no callback is specified, a Statement object is returned.
374 | *
375 | */
376 | static NODE_API_FUNC( prepare );
377 |
378 | /// @internal
379 | static void prepareAfter( uv_work_t *req );
380 | /// @internal
381 | static void prepareWork( uv_work_t *req );
382 |
383 | /** Performs a commit on the connection.
384 | *
385 | * This method performs a commit on the connection.
386 | * By default, inserts, updates, and deletes are not committed
387 | * upon disconnection from the database server.
388 | *
389 | * This method can be either synchronous or asynchronous depending on
390 | * whether or not a callback function is specified.
391 | * The callback function is of the form:
392 | *
393 | *
418 | *
419 | * @fn Connection::commit( Function callback )
420 | *
421 | * @param callback The optional callback function. ( type: Function )
422 | *
423 | */
424 | static NODE_API_FUNC( commit );
425 |
426 | /// @internal
427 | static void commitWork( uv_work_t *req );
428 |
429 | /** Performs a rollback on the connection.
430 | *
431 | * This method performs a rollback on the connection.
432 | *
433 | * This method can be either synchronous or asynchronous depending on
434 | * whether or not a callback function is specified.
435 | * The callback function is of the form:
436 | *
437 | *
489 | *
490 | * @fn Connection::connected()
491 | *
492 | * @return true if the connection is connected, false if not.
493 | *
494 | */
495 | static NODE_API_FUNC( connected );
496 |
497 | public:
498 | /// @internal
499 | a_sqlany_connection *conn;
500 | /// @internal
501 | unsigned int max_api_ver;
502 | /// @internal
503 | bool sqlca_connection;
504 | /// @internal
505 | uv_mutex_t conn_mutex;
506 | /// @internal
507 | Persistent _arg;
508 | /// @internal
509 | std::vector statements;
510 |
511 | /// @internal
512 | void removeStmt( class StmtObject *stmt );
513 | /// @internal
514 | void cleanupStmts( void );
515 | };
516 |
--------------------------------------------------------------------------------
/src/h/errors.h:
--------------------------------------------------------------------------------
1 | // ***************************************************************************
2 | // Copyright (c) 2021 SAP SE or an SAP affiliate company. All rights reserved.
3 | // ***************************************************************************
4 | #define JS_ERR_INVALID_OBJECT -2001
5 | #define JS_ERR_INVALID_ARGUMENTS -2002
6 | #define JS_ERR_CONNECTION_ALREADY_EXISTS -2003
7 | #define JS_ERR_INITIALIZING_DBCAPI -2004
8 | #define JS_ERR_NOT_CONNECTED -2005
9 | #define JS_ERR_BINDING_PARAMETERS -2006
10 | #define JS_ERR_GENERAL_ERROR -2007
11 | #define JS_ERR_RESULTSET -2008
12 | #define JS_ERR_NO_WIDE_STATEMENTS -2009
13 |
--------------------------------------------------------------------------------
/src/h/nodever_cover.h:
--------------------------------------------------------------------------------
1 | // ***************************************************************************
2 | // Copyright (c) 2021 SAP SE or an SAP affiliate company. All rights reserved.
3 | // ***************************************************************************
4 | #include
5 |
6 | #if NODE_MAJOR_VERSION == 0 && NODE_MINOR_VERSION == 10
7 | #define v010 1
8 | #define v012 0
9 | #elif NODE_MAJOR_VERSION == 0 && NODE_MINOR_VERSION == 12
10 | #define v010 0
11 | #define v012 1
12 | #else
13 | #define v010 0
14 | #define v012 0
15 | #endif
16 |
17 | #if v010
18 | #define NODE_API_FUNC( name ) Handle name ( const Arguments &args )
19 | #else
20 | #define NODE_API_FUNC( name ) void name ( const FunctionCallbackInfo &args )
21 | #endif
22 |
--------------------------------------------------------------------------------
/src/h/sacapi.h:
--------------------------------------------------------------------------------
1 | // ***************************************************************************
2 | // Copyright (c) 2021 SAP SE or an SAP affiliate company. All rights reserved.
3 | // ***************************************************************************
4 | //
5 | // Licensed under the Apache License, Version 2.0 (the "License");
6 | // you may not use this file except in compliance with the License.
7 | // You may obtain a copy of the License at
8 | //
9 | // http://www.apache.org/licenses/LICENSE-2.0
10 | //
11 | // Unless required by applicable law or agreed to in writing, software
12 | // distributed under the License is distributed on an "AS IS" BASIS,
13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | //
15 | // See the License for the specific language governing permissions and
16 | // limitations under the License.
17 | //
18 | // While not a requirement of the license, if you do modify this file, we
19 | // would appreciate hearing about it. Please email
20 | // sqlany_interfaces@sap.com
21 | //
22 | // ***************************************************************************
23 |
24 | #ifndef SACAPI_H
25 | #define SACAPI_H
26 |
27 | /** \mainpage SQL Anywhere C API
28 | *
29 | * \section intro_sec Introduction
30 | * The SQL Anywhere C application programming interface (API) is a data
31 | * access API for the C / C++ languages. The C API specification defines
32 | * a set of functions, variables and conventions that provide a consistent
33 | * database interface independent of the actual database being used. Using
34 | * the SQL Anywhere C API, your C / C++ applications have direct access to
35 | * SQL Anywhere database servers.
36 | *
37 | * The SQL Anywhere C API simplifies the creation of C and C++ wrapper
38 | * drivers for several interpreted programming languages including PHP,
39 | * Perl, Python, and Ruby. The SQL Anywhere C API is layered on top of the
40 | * DBLIB package and it was implemented with Embedded SQL.
41 | *
42 | * Although it is not a replacement for DBLIB, the SQL Anywhere C API
43 | * simplifies the creation of applications using C and C++. You do not need
44 | * an advanced knowledge of embedded SQL to use the SQL Anywhere C API.
45 | *
46 | * \section distribution Distribution of the API
47 | * The API is built as a dynamic link library (DLL) (\b dbcapi.dll) on
48 | * Microsoft Windows systems and as a shared object (\b libdbcapi.so) on
49 | * Unix systems. The DLL is statically linked to the DBLIB package of the
50 | * SQL Anywhere version on which it is built. When the dbcapi.dll file is
51 | * loaded, the corresponding dblibX.dll file is loaded by the operating
52 | * system. Applications using dbcapi.dll can either link directly to it
53 | * or load it dynamically. For more information about dynamic loading, see
54 | * the section "Dynamically Loading the DLL".
55 | *
56 | * Descriptions of the SQL Anywhere C API data types and entry points are
57 | * provided in the main header file (\b sacapi.h).
58 | *
59 | * \section dynamic_loading Dynamically Loading the DLL
60 | * The code to dynamically load the DLL is contained in the sacapidll.c
61 | * source file. Applications must use the sacapidll.h header file and
62 | * include the source code in sacapidll.c. You can use the
63 | * sqlany_initialize_interface method to dynamically load the DLL and
64 | * look up the entry points. Examples are provided with the SQL Anywhere
65 | * installation.
66 | *
67 | * \section threading_support Threading Support
68 | * The C API library is thread-unaware, meaning that the library does not
69 | * perform any tasks that require mutual exclusion. In order to allow the
70 | * library to work in threaded applications, there is only one rule to
71 | * follow: no more than one request is allowed on a single connection .
72 | * With this rule, the application is responsible for doing mutual exclusion
73 | * when accessing any connection-specific resource. This includes
74 | * connection handles, prepared statements, and result set objects.
75 | *
76 | * \version 2.0
77 | */
78 |
79 | /** \file sacapi.h
80 | * Main API header file.
81 | * This file describes all the data types and entry points of the API.
82 | */
83 |
84 | /** Version 1 was the initial version of the C/C++ API.
85 | *
86 | * You must define _SACAPI_VERSION as 1 or higher for this functionality.
87 | */
88 | #define SQLANY_API_VERSION_1 1
89 |
90 | /** Version 2 introduced the "_ex" functions and the ability to cancel requests.
91 | *
92 | * You must define _SACAPI_VERSION as 2 or higher for this functionality.
93 | */
94 | #define SQLANY_API_VERSION_2 2
95 |
96 | /** Version 3 introduced the "callback" function.
97 | *
98 | * You must define _SACAPI_VERSION as 3 or higher for this functionality.
99 | */
100 | #define SQLANY_API_VERSION_3 3
101 |
102 | /** Version 4 introduced NCHAR support and wide inserts.
103 | *
104 | * You must define _SACAPI_VERSION as 4 or higher for this functionality.
105 | */
106 | #define SQLANY_API_VERSION_4 4
107 |
108 | /** Version 5 introduced a way to reset sent data through sqlany_send_param_data()
109 | * and the A_FLOAT data type
110 | *
111 | * You must define _SACAPI_VERSION as 5 or higher for this functionality.
112 | */
113 | #define SQLANY_API_VERSION_5 5
114 |
115 | /** If the command line does not specify which version to build,
116 | * then build the latest version.
117 | */
118 | #ifndef _SACAPI_VERSION
119 | #define _SACAPI_VERSION SQLANY_API_VERSION_5
120 | #endif
121 |
122 | /** Returns the minimal error buffer size.
123 | */
124 | #define SACAPI_ERROR_SIZE 256
125 |
126 | #if defined(__cplusplus)
127 | extern "C" {
128 | #endif
129 |
130 | /** A handle to an interface context
131 | */
132 | typedef struct a_sqlany_interface_context a_sqlany_interface_context;
133 |
134 | /** A handle to a connection object
135 | */
136 | typedef struct a_sqlany_connection a_sqlany_connection;
137 |
138 | /** A handle to a statement object
139 | */
140 | typedef struct a_sqlany_stmt a_sqlany_stmt;
141 |
142 | /** A portable 32-bit signed value */
143 | typedef signed int sacapi_i32;
144 | /** A portable 32-bit unsigned value */
145 | typedef unsigned int sacapi_u32;
146 | /** A portable boolean value */
147 | typedef sacapi_i32 sacapi_bool;
148 |
149 | // TODO:Character set issues
150 |
151 | /** The run-time calling convention in use (Windows only).
152 | */
153 | #ifdef _WIN32
154 | #define _sacapi_entry_ __stdcall
155 | #endif
156 | #ifndef _sacapi_entry_
157 | #define _sacapi_entry_
158 | #endif
159 |
160 | /** Callback function type
161 | */
162 | #define SQLANY_CALLBACK _sacapi_entry_
163 |
164 | /** Parameter type for sqlany_register_callback function used to specify the address of the callback routine.
165 | */
166 | typedef int (SQLANY_CALLBACK *SQLANY_CALLBACK_PARM)();
167 |
168 | /** Specifies the data type being passed in or retrieved.
169 | */
170 | typedef enum a_sqlany_data_type
171 | {
172 | /// Invalid data type.
173 | A_INVALID_TYPE,
174 | /// Binary data. Binary data is treated as-is and no character set conversion is performed.
175 | A_BINARY,
176 | /// String data. The data where character set conversion is performed.
177 | A_STRING,
178 | /// Double data. Includes float values.
179 | A_DOUBLE,
180 | /// 64-bit integer.
181 | A_VAL64,
182 | /// 64-bit unsigned integer.
183 | A_UVAL64,
184 | /// 32-bit integer.
185 | A_VAL32,
186 | /// 32-bit unsigned integer.
187 | A_UVAL32,
188 | /// 16-bit integer.
189 | A_VAL16,
190 | /// 16-bit unsigned integer.
191 | A_UVAL16,
192 | /// 8-bit integer.
193 | A_VAL8,
194 | /// 8-bit unsigned integer.
195 | A_UVAL8
196 | #if _SACAPI_VERSION+0 >= SQLANY_API_VERSION_5
197 | ,
198 | //// Float precision data.
199 | A_FLOAT
200 | #endif
201 | } a_sqlany_data_type;
202 |
203 | /** Returns a description of the attributes of a data value.
204 | *
205 | * To view examples of the a_sqlany_data_value structure in use,
206 | * see any of the following sample files in the sdk\\dbcapi\\examples directory
207 | * of your SQL Anywhere installation:
208 | *
209 | *
210 | *
dbcapi_isql.cpp
211 | *
fetching_a_result_set.cpp
212 | *
send_retrieve_full_blob.cpp
213 | *
preparing_statements.cpp
214 | *
215 | */
216 | typedef struct a_sqlany_data_value
217 | {
218 | /// A pointer to user supplied buffer of data.
219 | char * buffer;
220 | /// The size of the buffer.
221 | size_t buffer_size;
222 | /// A pointer to the number of valid bytes in the buffer. This value must be less than buffer_size.
223 | size_t * length;
224 | /// The type of the data
225 | a_sqlany_data_type type;
226 | /// A pointer to indicate whether the last fetched data is NULL.
227 | sacapi_bool * is_null;
228 | #if _SACAPI_VERSION+0 >= SQLANY_API_VERSION_4
229 | /// Indicates whether the buffer value is an pointer to the actual value.
230 | sacapi_bool is_address;
231 | #endif
232 | } a_sqlany_data_value;
233 |
234 | /** A data direction enumeration.
235 | */
236 | typedef enum a_sqlany_data_direction
237 | {
238 | /// Invalid data direction.
239 | DD_INVALID = 0x0,
240 | /// Input-only host variables.
241 | DD_INPUT = 0x1,
242 | /// Output-only host variables.
243 | DD_OUTPUT = 0x2,
244 | /// Input and output host variables.
245 | DD_INPUT_OUTPUT = 0x3
246 | } a_sqlany_data_direction;
247 |
248 | /** A bind parameter structure used to bind parameter and prepared statements.
249 | *
250 | * To view examples of the a_sqlany_bind_param structure in use,
251 | * see any of the following sample files in the sdk\\dbcapi\\examples directory
252 | * of your SQL Anywhere installation:
253 | *
254 | *
255 | *
preparing_statements.cpp
256 | *
send_retrieve_full_blob.cpp
257 | *
send_retrieve_part_blob.cpp
258 | *
259 | * \sa sqlany_execute()
260 | */
261 | typedef struct a_sqlany_bind_param
262 | {
263 | /// The direction of the data. (input, output, input_output)
264 | a_sqlany_data_direction direction;
265 | /// The actual value of the data.
266 | a_sqlany_data_value value;
267 | /// Name of the bind parameter. This is only used by sqlany_describe_bind_param().
268 | char *name;
269 | } a_sqlany_bind_param;
270 |
271 | /** An enumeration of the native types of values as described by the server.
272 | *
273 | * The value types correspond to the embedded SQL data types.
274 | *
275 | * \hideinitializers
276 | * \sa sqlany_get_column_info(), a_sqlany_column_info
277 | */
278 | typedef enum a_sqlany_native_type
279 | {
280 | /// No data type.
281 | DT_NOTYPE = 0,
282 | /// Null-terminated character string that is a valid date.
283 | DT_DATE = 384,
284 | /// Null-terminated character string that is a valid time.
285 | DT_TIME = 388,
286 | /// Null-terminated character string that is a valid timestamp.
287 | DT_TIMESTAMP = 392,
288 | /// Varying length character string, in the CHAR character set, with a two-byte length field. The maximum length is 32765 bytes. When sending data, you must set the length field. When fetching data, the database server sets the length field. The data is not null-terminated or blank-padded.
289 | DT_VARCHAR = 448,
290 | /// Fixed-length blank-padded character string, in the CHAR character set. The maximum length, specified in bytes, is 32767. The data is not null-terminated.
291 | DT_FIXCHAR = 452,
292 | /// Long varying length character string, in the CHAR character set.
293 | DT_LONGVARCHAR = 456,
294 | /// Null-terminated character string, in the CHAR character set. The string is blank-padded if the database is initialized with blank-padded strings.
295 | DT_STRING = 460,
296 | /// 8-byte floating-point number.
297 | DT_DOUBLE = 480,
298 | /// 4-byte floating-point number.
299 | DT_FLOAT = 482,
300 | /// Packed decimal number (proprietary format).
301 | DT_DECIMAL = 484,
302 | /// 32-bit signed integer.
303 | DT_INT = 496,
304 | /// 16-bit signed integer.
305 | DT_SMALLINT = 500,
306 | /// Varying length binary data with a two-byte length field. The maximum length is 32765 bytes. When supplying information to the database server, you must set the length field. When fetching information from the database server, the server sets the length field.
307 | DT_BINARY = 524,
308 | /// Long binary data.
309 | DT_LONGBINARY = 528,
310 | /// 8-bit signed integer.
311 | DT_TINYINT = 604,
312 | /// 64-bit signed integer.
313 | DT_BIGINT = 608,
314 | /// 32-bit unsigned integer.
315 | DT_UNSINT = 612,
316 | /// 16-bit unsigned integer.
317 | DT_UNSSMALLINT = 616,
318 | /// 64-bit unsigned integer.
319 | DT_UNSBIGINT = 620,
320 | /// 8-bit signed integer.
321 | DT_BIT = 624,
322 | /// Null-terminated character string, in the NCHAR character set. The string is blank-padded if the database is initialized with blank-padded strings.
323 | DT_NSTRING = 628,
324 | /// Fixed-length blank-padded character string, in the NCHAR character set. The maximum length, specified in bytes, is 32767. The data is not null-terminated.
325 | DT_NFIXCHAR = 632,
326 | /// Varying length character string, in the NCHAR character set, with a two-byte length field. The maximum length is 32765 bytes. When sending data, you must set the length field. When fetching data, the database server sets the length field. The data is not null-terminated or blank-padded.
327 | DT_NVARCHAR = 636,
328 | /// Long varying length character string, in the NCHAR character set.
329 | DT_LONGNVARCHAR = 640
330 | } a_sqlany_native_type;
331 |
332 | /** Returns column metadata information.
333 | *
334 | * sqlany_get_column_info() can be used to populate this structure.
335 | *
336 | * To view an example of the a_sqlany_column_info structure in use,
337 | * see the following sample file in the sdk\\dbcapi\\examples
338 | * directory of your SQL Anywhere installation.
339 | *
340 | *
341 | *
dbcapi_isql.cpp
342 | *
343 | */
344 | typedef struct a_sqlany_column_info
345 | {
346 | /// The name of the column (null-terminated).
347 | /// The string can be referenced as long as the result set object is not freed.
348 | char * name;
349 | /// The column data type.
350 | a_sqlany_data_type type;
351 | /// The native type of the column in the database.
352 | a_sqlany_native_type native_type;
353 | /// The precision.
354 | unsigned short precision;
355 | /// The scale.
356 | unsigned short scale;
357 | /// The maximum size a data value in this column can take.
358 | size_t max_size;
359 | /// Indicates whether a value in the column can be null.
360 | sacapi_bool nullable;
361 | #if _SACAPI_VERSION+0 >= SQLANY_API_VERSION_4
362 | /// The name of the table (null-terminated).
363 | /// The string can be referenced as long as the result set object is not freed.
364 | char * table_name;
365 | /// The name of the owner (null-terminated).
366 | /// The string can be referenced as long as the result set object is not freed.
367 | char * owner_name;
368 | /// Indicates whether the column is bound to a user buffer.
369 | sacapi_bool is_bound;
370 | /// Information about the bound column.
371 | a_sqlany_data_value binding;
372 | #endif
373 | } a_sqlany_column_info;
374 |
375 | /** Gets information about the currently bound parameters.
376 | *
377 | * sqlany_get_bind_param_info() can be used to populate this structure.
378 | *
379 | * To view examples of the a_sqlany_bind_param_info structure in use,
380 | * see any of the following sample files in the sdk\\dbcapi\\examples
381 | * directory of your SQL Anywhere installation.
382 | *
383 | *
384 | *
preparing_statements.cpp
385 | *
send_retrieve_full_blob.cpp
386 | *
send_retrieve_part_blob.cpp
387 | *
388 | * \sa sqlany_execute()
389 | */
390 | typedef struct a_sqlany_bind_param_info
391 | {
392 | /// A pointer to the name of the parameter.
393 | char * name;
394 | /// The direction of the parameter.
395 | a_sqlany_data_direction direction;
396 | /// Information about the bound input value.
397 | a_sqlany_data_value input_value;
398 | /// Information about the bound output value.
399 | a_sqlany_data_value output_value;
400 |
401 | #if _SACAPI_VERSION+0 >= SQLANY_API_VERSION_4
402 | /// The native type of the column in the database.
403 | a_sqlany_native_type native_type;
404 | /// The precision.
405 | unsigned short precision;
406 | /// The scale.
407 | unsigned short scale;
408 | /// The maximum size a data value in this column can take.
409 | size_t max_size;
410 | #endif
411 | } a_sqlany_bind_param_info;
412 |
413 | /** Returns metadata information about a column value in a result set.
414 | *
415 | * sqlany_get_data_info() can be used
416 | * to populate this structure with information about what was last retrieved by a fetch operation.
417 | *
418 | * To view an example of the a_sqlany_data_info structure in use,
419 | * see the following sample file in the sdk\\dbcapi\\examples directory
420 | * of your SQL Anywhere installation:
421 | *
422 | *
423 | *
send_retrieve_part_blob.cpp
424 | *
425 | * \sa sqlany_get_data_info()
426 | */
427 | typedef struct a_sqlany_data_info
428 | {
429 | /// The type of the data in the column.
430 | a_sqlany_data_type type;
431 | /// Indicates whether the last fetched data is NULL.
432 | /// This field is only valid after a successful fetch operation.
433 | sacapi_bool is_null;
434 | /// The total number of bytes available to be fetched.
435 | /// This field is only valid after a successful fetch operation.
436 | size_t data_size;
437 | } a_sqlany_data_info;
438 |
439 | /** An enumeration of the callback types.
440 | *
441 | * The callback types correspond to the embedded SQL callback types.
442 | *
443 | * \hideinitializers
444 | * \sa sqlany_register_callback()
445 | */
446 | typedef enum a_sqlany_callback_type {
447 | /// This function is called just before a database request is sent to the server.
448 | /// CALLBACK_START is used only on Windows operating systems.
449 | CALLBACK_START = 0,
450 | /// This function is called repeatedly by the interface library while the database server or client library is busy processing your database request.
451 | CALLBACK_WAIT,
452 | /// This function is called after the response to a database request has been received by the DBLIB interface DLL.
453 | /// CALLBACK_FINISH is used only on Windows operating systems.
454 | CALLBACK_FINISH,
455 | /// This function is called when messages are received from the server during the processing of a request.
456 | /// Messages can be sent to the client application from the database server using the SQL MESSAGE statement.
457 | /// Messages can also be generated by long running database server statements.
458 | CALLBACK_MESSAGE = 7,
459 | /// This function is called when the database server is about to drop a connection because of a liveness timeout,
460 | /// through a DROP CONNECTION statement, or because the database server is being shut down.
461 | /// The connection name conn_name is passed in to allow you to distinguish between connections.
462 | /// If the connection was not named, it has a value of NULL.
463 | CALLBACK_CONN_DROPPED,
464 | /// This function is called once for each debug message and is passed a null-terminated string containing the text of the debug message.
465 | /// A debug message is a message that is logged to the LogFile file. In order for a debug message to be passed to this callback, the LogFile
466 | /// connection parameter must be used. The string normally has a newline character (\n) immediately before the terminating null character.
467 | CALLBACK_DEBUG_MESSAGE,
468 | /// This function is called when a file transfer requires validation.
469 | /// If the client data transfer is being requested during the execution of indirect statements such as from within a stored procedure,
470 | /// the client library will not allow a transfer unless the client application has registered a validation callback and the response from
471 | /// the callback indicates that the transfer may take place.
472 | CALLBACK_VALIDATE_FILE_TRANSFER
473 | } a_sqlany_callback_type;
474 |
475 | /** An enumeration of the message types for the MESSAGE callback.
476 | *
477 | * \hideinitializers
478 | * \sa sqlany_register_callback()
479 | */
480 | typedef enum a_sqlany_message_type {
481 | /// The message type was INFO.
482 | MESSAGE_TYPE_INFO = 0,
483 | /// The message type was WARNING.
484 | MESSAGE_TYPE_WARNING,
485 | /// The message type was ACTION.
486 | MESSAGE_TYPE_ACTION,
487 | /// The message type was STATUS.
488 | MESSAGE_TYPE_STATUS,
489 | /// The message type was PROGRESS.
490 | /// This type of message is generated by long running database server statements such as BACKUP DATABASE and LOAD TABLE.
491 | MESSAGE_TYPE_PROGRESS
492 | } a_sqlany_message_type;
493 |
494 | /** Initializes the interface.
495 | *
496 | * The following example demonstrates how to initialize the SQL Anywhere C API DLL:
497 | *
498 | *
506 | *
507 | * \param app_name A string that names the application that is using the API. For example, "PHP", "PERL", or "RUBY".
508 | * \param api_version The version of the compiled application.
509 | * \param version_available An optional argument to return the maximum supported API version.
510 | * \return 1 on success, 0 otherwise
511 | * \sa sqlany_fini()
512 | */
513 | sacapi_bool sqlany_init( const char * app_name, sacapi_u32 api_version, sacapi_u32 * version_available );
514 |
515 | #if _SACAPI_VERSION+0 >= SQLANY_API_VERSION_2
516 | /** Initializes the interface using a context.
517 | *
518 | * \param app_name A string that names the API used, for example "PHP", "PERL", or "RUBY".
519 | * \param api_version The current API version that the application is using.
520 | * This should normally be one of the SQLANY_API_VERSION_* macros
521 | * \param version_available An optional argument to return the maximum API version that is supported.
522 | * \return a context object on success and NULL on failure.
523 | * \sa sqlany_fini_ex()
524 | */
525 | a_sqlany_interface_context *sqlany_init_ex( const char * app_name, sacapi_u32 api_version, sacapi_u32 * version_available );
526 | #endif
527 |
528 | /** Finalizes the interface.
529 | *
530 | * Frees any resources allocated by the API.
531 | *
532 | * \sa sqlany_init()
533 | */
534 | void sqlany_fini();
535 | #if _SACAPI_VERSION+0 >= SQLANY_API_VERSION_2
536 | /** Finalize the interface that was created using the specified context.
537 | * Frees any resources allocated by the API.
538 | * \param context A context object that was returned from sqlany_init_ex()
539 | * \sa sqlany_init_ex()
540 | */
541 | void sqlany_fini_ex( a_sqlany_interface_context *context );
542 | #endif
543 |
544 | /** Creates a connection object.
545 | *
546 | * You must create an API connection object before establishing a database connection. Errors can be retrieved
547 | * from the connection object. Only one request can be processed on a connection at a time. In addition,
548 | * not more than one thread is allowed to access a connection object at a time. Undefined behavior or a failure
549 | * occurs when multiple threads attempt to access a connection object simultaneously.
550 | *
551 | * \return A connection object
552 | * \sa sqlany_connect(), sqlany_disconnect()
553 | */
554 | a_sqlany_connection * sqlany_new_connection( void );
555 | #if _SACAPI_VERSION+0 >= SQLANY_API_VERSION_2
556 | /** Creates a connection object using a context.
557 | * An API connection object needs to be created before a database connection is established. Errors can be retrieved
558 | * from the connection object. Only one request can be processed on a connection at a time. In addition,
559 | * not more than one thread is allowed to access a connection object at a time. If multiple threads attempt
560 | * to access a connection object simultaneously, then undefined behavior/crashes will occur.
561 | * \param context A context object that was returned from sqlany_init_ex()
562 | * \return A connection object
563 | * \sa sqlany_connect(), sqlany_disconnect(), sqlany_init_ex()
564 | */
565 | a_sqlany_connection *sqlany_new_connection_ex( a_sqlany_interface_context *context );
566 | #endif
567 |
568 | /** Frees the resources associated with a connection object.
569 | *
570 | * \param sqlany_conn A connection object created with sqlany_new_connection().
571 | * \sa sqlany_new_connection()
572 | */
573 | void sqlany_free_connection( a_sqlany_connection *sqlany_conn );
574 |
575 | /** Creates a connection object based on a supplied DBLIB SQLCA pointer.
576 | *
577 | * \param arg A void * pointer to a DBLIB SQLCA object.
578 | * \return A connection object.
579 | * \sa sqlany_new_connection(), sqlany_execute(), sqlany_execute_direct(), sqlany_execute_immediate(), sqlany_prepare()
580 | */
581 | a_sqlany_connection * sqlany_make_connection( void * arg );
582 | #if _SACAPI_VERSION+0 >= SQLANY_API_VERSION_2
583 | /** Creates a connection object based on a supplied DBLIB SQLCA pointer and context.
584 | * \param context A valid context object that was created by sqlany_init_ex()
585 | * \param arg A void * pointer to a DBLIB SQLCA object.
586 | * \return A connection object.
587 | * \sa sqlany_init_ex(), sqlany_execute(), sqlany_execute_direct(), sqlany_execute_immediate(), sqlany_prepare()
588 | */
589 | a_sqlany_connection *sqlany_make_connection_ex( a_sqlany_interface_context *context, void *arg );
590 | #endif
591 |
592 | /** Creates a connection to a SQL Anywhere database server using the supplied connection object and connection string.
593 | *
594 | * The supplied connection object must first be allocated using sqlany_new_connection().
595 | *
596 | * The following example demonstrates how to retrieve the error code of a failed connection attempt:
597 | *
598 | *
612 | *
613 | * \param sqlany_conn A connection object created by sqlany_new_connection().
614 | * \param str A SQL Anywhere connection string.
615 | * \return 1 if the connection is established successfully or 0 when the connection fails. Use sqlany_error() to
616 | * retrieve the error code and message.
617 | * \sa sqlany_new_connection(), sqlany_error()
618 | */
619 | sacapi_bool sqlany_connect( a_sqlany_connection * sqlany_conn, const char * str );
620 |
621 | /** Disconnects an already established SQL Anywhere connection.
622 | *
623 | * All uncommitted transactions are rolled back.
624 | *
625 | * \param sqlany_conn A connection object with a connection established using sqlany_connect().
626 | * \return 1 when successful or 0 when unsuccessful.
627 | * \sa sqlany_connect(), sqlany_new_connection()
628 | */
629 | sacapi_bool sqlany_disconnect( a_sqlany_connection * sqlany_conn );
630 |
631 | #if _SACAPI_VERSION+0 >= SQLANY_API_VERSION_2
632 | /** Cancel an outstanding request on a connection.
633 | * This function can be used to cancel an outstanding request on a specific connection.
634 | * \param sqlany_conn A connection object with a connection established using sqlany_connect().
635 | */
636 | void sqlany_cancel( a_sqlany_connection * sqlany_conn );
637 | #endif
638 |
639 | /** Executes the supplied SQL statement immediately without returning a result set.
640 | *
641 | * This function is useful for SQL statements that do not return a result set.
642 | *
643 | * \param sqlany_conn A connection object with a connection established using sqlany_connect().
644 | * \param sql A string representing the SQL statement to be executed.
645 | * \return 1 on success or 0 on failure.
646 | */
647 | sacapi_bool sqlany_execute_immediate( a_sqlany_connection * sqlany_conn, const char * sql );
648 |
649 | /** Prepares a supplied SQL string.
650 | *
651 | * Execution does not happen until sqlany_execute() is
652 | * called. The returned statement object should be freed using sqlany_free_stmt().
653 | *
654 | * The following statement demonstrates how to prepare a SELECT SQL string:
655 | *
656 | *
666 | *
667 | * \param sqlany_conn A connection object with a connection established using sqlany_connect().
668 | * \param sql_str The SQL statement to be prepared.
669 | * \return A handle to a SQL Anywhere statement object. The statement object can be used by sqlany_execute()
670 | * to execute the statement.
671 | * \sa sqlany_free_stmt(), sqlany_connect(), sqlany_execute(), sqlany_num_params(), sqlany_describe_bind_param(), sqlany_bind_param()
672 | */
673 | a_sqlany_stmt * sqlany_prepare( a_sqlany_connection * sqlany_conn, const char * sql_str );
674 |
675 | /** Frees resources associated with a prepared statement object.
676 | *
677 | * \param sqlany_stmt A statement object returned by the successful execution of sqlany_prepare() or sqlany_execute_direct().
678 | * \sa sqlany_prepare(), sqlany_execute_direct()
679 | */
680 | void sqlany_free_stmt( a_sqlany_stmt * sqlany_stmt );
681 |
682 | /** Returns the number of parameters expected for a prepared statement.
683 | *
684 | * \param sqlany_stmt A statement object returned by the successful execution of sqlany_prepare().
685 | * \return The expected number of parameters, or -1 if the statement object is not valid.
686 | * \sa sqlany_prepare()
687 | */
688 | sacapi_i32 sqlany_num_params( a_sqlany_stmt * sqlany_stmt );
689 |
690 | /** Describes the bind parameters of a prepared statement.
691 | *
692 | * This function allows the caller to determine information about prepared statement parameters. The type of prepared
693 | * statement, stored procedured or a DML, determines the amount of information provided. The direction of the parameters
694 | * (input, output, or input-output) are always provided.
695 | *
696 | * \param sqlany_stmt A statement prepared successfully using sqlany_prepare().
697 | * \param index The index of the parameter. This number must be between 0 and sqlany_num_params() - 1.
698 | * \param param An a_sqlany_bind_param structure that is populated with information.
699 | * \return 1 when successful or 0 when unsuccessful.
700 | * \sa sqlany_bind_param(), sqlany_prepare()
701 | */
702 | sacapi_bool sqlany_describe_bind_param( a_sqlany_stmt * sqlany_stmt, sacapi_u32 index, a_sqlany_bind_param * param );
703 |
704 | /** Bind a user-supplied buffer as a parameter to the prepared statement.
705 | *
706 | * \param sqlany_stmt A statement prepared successfully using sqlany_prepare().
707 | * \param index The index of the parameter. This number must be between 0 and sqlany_num_params() - 1.
708 | * \param param An a_sqlany_bind_param structure description of the parameter to be bound.
709 | * \return 1 on success or 0 on unsuccessful.
710 | * \sa sqlany_describe_bind_param()
711 | */
712 | sacapi_bool sqlany_bind_param( a_sqlany_stmt * sqlany_stmt, sacapi_u32 index, a_sqlany_bind_param * param );
713 |
714 | /** Sends data as part of a bound parameter.
715 | *
716 | * This method can be used to send a large amount of data for a bound parameter in chunks.
717 | * This method can be used only when the batch size is 1.
718 | *
719 | * \param sqlany_stmt A statement prepared successfully using sqlany_prepare().
720 | * \param index The index of the parameter. This should be a number between 0 and sqlany_num_params() - 1.
721 | * \param buffer The data to be sent.
722 | * \param size The number of bytes to send.
723 | * \return 1 on success or 0 on failure.
724 | * \sa sqlany_prepare()
725 | */
726 | sacapi_bool sqlany_send_param_data( a_sqlany_stmt * sqlany_stmt, sacapi_u32 index, char * buffer, size_t size );
727 |
728 |
729 | #if _SACAPI_VERSION+0 >= SQLANY_API_VERSION_5
730 | /** Clears param data that was previously been set using \sa sqlany_send_param_data()
731 | *
732 | * This method can be used to clear data that was previously been sent using sqlany_send_param_data()
733 | * If no param data was previously sent, nothing is changed.
734 | *
735 | * \param sqlany_stmt A statement prepared successfully using sqlany_prepare().
736 | * \param index The index of the parameter. This should be a number between 0 and sqlany_num_params() - 1.
737 | * \return 1 on success or 0 on failure
738 | * \sa sqlany_prepare(), sqlany_send_param_data()
739 | */
740 | sacapi_bool sqlany_reset_param_data( a_sqlany_stmt * sqlany_stmt, sacapi_u32 index );
741 |
742 | /** Retrieves the length of the last error message stored in the connection object
743 | * including the NULL terminator. If there is no error, 0 is returned.
744 | *
745 | * \param sqlany_conn A connection object returned from sqlany_new_connection().
746 | * \return The length of the last error message including the NULL terminator.
747 | */
748 | size_t sqlany_error_length( a_sqlany_connection * sqlany_conn );
749 | #endif
750 |
751 | #if _SACAPI_VERSION+0 >= SQLANY_API_VERSION_4
752 | /** Sets the size of the row array for a batch execute.
753 | *
754 | * The batch size is used only for an INSERT statement. The default batch size is 1.
755 | * A value greater than 1 indicates a wide insert.
756 | *
757 | * \param sqlany_stmt A statement prepared successfully using sqlany_prepare().
758 | * \param num_rows The number of rows for batch execution. The value must be 1 or greater.
759 | * \return 1 on success or 0 on failure.
760 | * \sa sqlany_bind_param(), sqlany_get_batch_size()
761 | */
762 | sacapi_bool sqlany_set_batch_size( a_sqlany_stmt * sqlany_stmt, sacapi_u32 num_rows );
763 |
764 | /** Sets the bind type of parameters.
765 | *
766 | * The default value is 0, which indicates column-wise binding. A non-zero value indicates
767 | * row-wise binding and specifies the byte size of the data structure that stores the row.
768 | * The parameter is bound to the first element in a contiguous array of values. The address
769 | * offset to the next element is computed based on the bind type:
770 | *
771 | *
772 | *
Column-wise binding - the byte size of the parameter type
773 | *
Row-wise binding - the row_size
774 | *
775 | *
776 | * \param sqlany_stmt A statement prepared successfully using sqlany_prepare().
777 | * \param row_size The byte size of the row. A value of 0 indicates column-wise binding and a positive value indicates row-wise binding.
778 | * \return 1 on success or 0 on failure.
779 | * \sa sqlany_bind_param()
780 | */
781 | sacapi_bool sqlany_set_param_bind_type( a_sqlany_stmt * sqlany_stmt, size_t row_size );
782 |
783 | /** Retrieves the size of the row array for a batch execute.
784 | *
785 | * \param sqlany_stmt A statement prepared successfully using sqlany_prepare().
786 | * \return The size of the row array.
787 | * \sa sqlany_set_batch_size()
788 | */
789 | sacapi_u32 sqlany_get_batch_size( a_sqlany_stmt * sqlany_stmt );
790 |
791 | /** Sets the size of the row set to be fetched by the sqlany_fetch_absolute() and sqlany_fetch_next() functions.
792 | *
793 | * The default size of the row set is 1. Specifying num_rows to be a value greater than 1 indicates a wide fetch.
794 | *
795 | * \param sqlany_stmt A statement prepared successfully using sqlany_prepare().
796 | * \param num_rows The size of the row set. The value must be 1 or greater.
797 | * \return 1 on success or 0 on failure.
798 | * \sa sqlany_bind_column(), sqlany_fetch_absolute(), sqlany_fetch_next(), sqlany_get_rowset_size()
799 | */
800 | sacapi_bool sqlany_set_rowset_size( a_sqlany_stmt * sqlany_stmt, sacapi_u32 num_rows );
801 |
802 | /** Retrieves the size of the row set to be fetched by the sqlany_fetch_absolute() and sqlany_fetch_next() functions.
803 | *
804 | * \param sqlany_stmt A statement prepared successfully using sqlany_prepare().
805 | * \return The size of the row set, or 0 if the statement does not return a result set.
806 | * \sa sqlany_set_rowset_size(), sqlany_fetch_absolute(), sqlany_fetch_next()
807 | */
808 | sacapi_u32 sqlany_get_rowset_size( a_sqlany_stmt * sqlany_stmt );
809 |
810 | /** Sets the bind type of columns.
811 | *
812 | * The default value is 0, which indicates column-wise binding. A non-zero value indicates
813 | * row-wise binding and specifies the byte size of the data structure that stores the row.
814 | * The column is bound to the first element in a contiguous array of values. The address
815 | * offset to the next element is computed based on the bind type:
816 | *
817 | *
818 | *
Column-wise binding - the byte size of the column type
819 | *
Row-wise binding - the row_size
820 | *
821 | *
822 | * \param sqlany_stmt A statement prepared successfully using sqlany_prepare().
823 | * \param row_size The byte size of the row. A value of 0 indicates column-wise binding and a positive value indicates row-wise binding.
824 | * \return 1 on success or 0 on failure.
825 | * \sa sqlany_bind_column()
826 | */
827 | sacapi_bool sqlany_set_column_bind_type( a_sqlany_stmt * sqlany_stmt, sacapi_u32 row_size );
828 |
829 | /** Binds a user-supplied buffer as a result set column to the prepared statement.
830 | *
831 | * If the size of the fetched row set is greater than 1, the buffer must be large enough to
832 | * hold the data of all of the rows in the row set. This function can also be used to clear the
833 | * binding of a column by specifying value to be NULL.
834 | *
835 | * \param sqlany_stmt A statement prepared successfully using sqlany_prepare().
836 | * \param index The index of the column. This number must be between 0 and sqlany_num_cols() - 1.
837 | * \param value An a_sqlany_data_value structure describing the bound buffers, or NULL to clear previous binding information.
838 | * \return 1 on success or 0 on unsuccessful.
839 | * \sa sqlany_clear_column_bindings(), sqlany_set_rowset_size()
840 | */
841 | sacapi_bool sqlany_bind_column( a_sqlany_stmt * sqlany_stmt, sacapi_u32 index, a_sqlany_data_value * value );
842 |
843 | /** Removes all column bindings defined using sqlany_bind_column().
844 | *
845 | * \param sqlany_stmt A statement prepared successfully using sqlany_prepare().
846 | * \return 1 on success or 0 on failure.
847 | * \sa sqlany_bind_column()
848 | */
849 | sacapi_bool sqlany_clear_column_bindings( a_sqlany_stmt * sqlany_stmt );
850 |
851 | /** Returns the number of rows fetched.
852 | *
853 | * In general, the number of rows fetched is equal to the size specified by the sqlany_set_rowset_size() function. The
854 | * exception is when there are fewer rows from the fetch position to the end of the result set than specified, in which
855 | * case the number of rows fetched is smaller than the specified row set size. The function returns -1 if the last fetch
856 | * was unsuccessful or if the statement has not been executed. The function returns 0 if the statement has been executed
857 | * but no fetching has been done.
858 | *
859 | * \param sqlany_stmt A statement prepared successfully using sqlany_prepare().
860 | * \return The number of rows fetched or -1 on failure.
861 | * \sa sqlany_bind_column(), sqlany_fetch_next(), sqlany_fetch_absolute()
862 | */
863 | sacapi_i32 sqlany_fetched_rows( a_sqlany_stmt * sqlany_stmt );
864 |
865 | /** Sets the current row in the fetched row set.
866 | *
867 | * When a sqlany_fetch_absolute() or sqlany_fetch_next() function is executed, a row set
868 | * is created and the current row is set to be the first row in the row set. The functions
869 | * sqlany_get_column(), sqlany_get_data(), sqlany_get_data_info() are used to retrieve data
870 | * at the current row.
871 | *
872 | * \param sqlany_stmt A statement prepared successfully using sqlany_prepare().
873 | * \param row_num The row number within the row set. The valid values are from 0 to sqlany_fetched_rows() - 1.
874 | * \return 1 on success or 0 on failure.
875 | * \sa sqlany_set_rowset_size(), sqlany_get_column(), sqlany_get_data(), sqlany_get_data_info(), sqlany_fetch_absolute(), sqlany_fetch_next()
876 | */
877 | sacapi_bool sqlany_set_rowset_pos( a_sqlany_stmt * sqlany_stmt, sacapi_u32 row_num );
878 | #endif
879 |
880 | /** Resets a statement to its prepared state condition.
881 | *
882 | * \param sqlany_stmt A statement prepared successfully using sqlany_prepare().
883 | * \return 1 on success, 0 on failure.
884 | * \sa sqlany_prepare()
885 | */
886 | sacapi_bool sqlany_reset( a_sqlany_stmt * sqlany_stmt );
887 |
888 | /** Retrieves information about the parameters that were bound using sqlany_bind_param().
889 | *
890 | * \param sqlany_stmt A statement prepared successfully using sqlany_prepare().
891 | * \param index The index of the parameter. This number should be between 0 and sqlany_num_params() - 1.
892 | * \param info A sqlany_bind_param_info buffer to be populated with the bound parameter's information.
893 | * \return 1 on success or 0 on failure.
894 | * \sa sqlany_bind_param(), sqlany_describe_bind_param(), sqlany_prepare()
895 | */
896 | sacapi_bool sqlany_get_bind_param_info( a_sqlany_stmt * sqlany_stmt, sacapi_u32 index, a_sqlany_bind_param_info * info );
897 |
898 | /** Executes a prepared statement.
899 | *
900 | * You can use sqlany_num_cols() to verify if the executed statement returned a result set.
901 | *
902 | * The following example shows how to execute a statement that does not return a result set:
903 | *
904 | *
929 | *
930 | * \param sqlany_stmt A statement prepared successfully using sqlany_prepare().
931 | * \return 1 if the statement is executed successfully or 0 on failure.
932 | * \sa sqlany_prepare()
933 | */
934 | sacapi_bool sqlany_execute( a_sqlany_stmt * sqlany_stmt );
935 |
936 | /** Executes the SQL statement specified by the string argument and possibly returns a result set.
937 | *
938 | * Use this method to prepare and execute a statement,
939 | * or instead of calling sqlany_prepare() followed by sqlany_execute().
940 | *
941 | * The following example shows how to execute a statement that returns a result set:
942 | *
943 | *
957 | *
958 | * Note: This function cannot be used for executing a SQL statement with parameters.
959 | *
960 | * \param sqlany_conn A connection object with a connection established using sqlany_connect().
961 | * \param sql_str A SQL string. The SQL string should not have parameters such as ?.
962 | * \return A statement handle if the function executes successfully, NULL when the function executes unsuccessfully.
963 | * \sa sqlany_fetch_absolute(), sqlany_fetch_next(), sqlany_num_cols(), sqlany_get_column()
964 | */
965 | a_sqlany_stmt * sqlany_execute_direct( a_sqlany_connection * sqlany_conn, const char * sql_str );
966 |
967 | /** Moves the current row in the result set to the specified row number and then fetches
968 | * rows of data starting from the current row.
969 | *
970 | * The number of rows fetched is set using the sqlany_set_rowset_size() function. By default, one row is returned.
971 | *
972 | * \param sqlany_stmt A statement object that was executed by
973 | * sqlany_execute() or sqlany_execute_direct().
974 | * \param row_num The row number to be fetched. The first row is 1, the last row is -1.
975 | * \return 1 if the fetch was successfully, 0 when the fetch is unsuccessful.
976 | * \sa sqlany_execute_direct(), sqlany_execute(), sqlany_error(), sqlany_fetch_next(), sqlany_set_rowset_size()
977 | */
978 | sacapi_bool sqlany_fetch_absolute( a_sqlany_stmt * sqlany_stmt, sacapi_i32 row_num );
979 |
980 | /** Returns the next set of rows from the result set.
981 | *
982 | * When the result object is first created, the current row
983 | * pointer is set to before the first row, that is, row 0.
984 | * This function first advances the row pointer to the next
985 | * unfetched row and then fetches rows of data starting from
986 | * that row. The number of rows fetched is set by the
987 | * sqlany_set_rowset_size() function. By default, one row is returned.
988 | *
989 | * \param sqlany_stmt A statement object that was executed by
990 | * sqlany_execute() or sqlany_execute_direct().
991 | * \return 1 if the fetch was successfully, 0 when the fetch is unsuccessful.
992 | * \sa sqlany_fetch_absolute(), sqlany_execute_direct(), sqlany_execute(), sqlany_error(), sqlany_set_rowset_size()
993 | */
994 | sacapi_bool sqlany_fetch_next( a_sqlany_stmt * sqlany_stmt );
995 |
996 | /** Advances to the next result set in a multiple result set query.
997 | *
998 | * If a query (such as a call to a stored procedure) returns multiple result sets, then this function
999 | * advances from the current result set to the next.
1000 | *
1001 | * The following example demonstrates how to advance to the next result set in a multiple result set query:
1002 | *
1003 | *
1014 | *
1015 | * \param sqlany_stmt A statement object executed by
1016 | * sqlany_execute() or sqlany_execute_direct().
1017 | * \return 1 if the statement successfully advances to the next result set, 0 otherwise.
1018 | * \sa sqlany_execute_direct(), sqlany_execute()
1019 | */
1020 | sacapi_bool sqlany_get_next_result( a_sqlany_stmt * sqlany_stmt );
1021 |
1022 | /** Returns the number of rows affected by execution of the prepared statement.
1023 | *
1024 | * \param sqlany_stmt A statement that was prepared and executed successfully with no result set returned.
1025 | * For example, an INSERT, UPDATE or DELETE statement was executed.
1026 | * \return The number of rows affected or -1 on failure.
1027 | * \sa sqlany_execute(), sqlany_execute_direct()
1028 | */
1029 | sacapi_i32 sqlany_affected_rows( a_sqlany_stmt * sqlany_stmt );
1030 |
1031 | /** Returns number of columns in the result set.
1032 | *
1033 | * \param sqlany_stmt A statement object created by sqlany_prepare() or sqlany_execute_direct().
1034 | * \return The number of columns in the result set or -1 on a failure.
1035 | * \sa sqlany_execute(), sqlany_execute_direct(), sqlany_prepare()
1036 | */
1037 | sacapi_i32 sqlany_num_cols( a_sqlany_stmt * sqlany_stmt );
1038 |
1039 | /** Returns the number of rows in the result set.
1040 | *
1041 | * By default this function only returns an estimate. To return an exact count, set the row_counts option
1042 | * on the connection.
1043 | *
1044 | * \param sqlany_stmt A statement object that was executed by
1045 | * sqlany_execute() or sqlany_execute_direct().
1046 | * \return The number rows in the result set. If the number of rows is an estimate, the number returned is
1047 | * negative and the estimate is the absolute value of the returned integer. The value returned is positive
1048 | * if the number of rows is exact.
1049 | * \sa sqlany_execute_direct(), sqlany_execute()
1050 | */
1051 | sacapi_i32 sqlany_num_rows( a_sqlany_stmt * sqlany_stmt );
1052 |
1053 | /** Fills the supplied buffer with the value fetched for the specified column at the current row.
1054 | *
1055 | * When a sqlany_fetch_absolute() or sqlany_fetch_next() function is executed, a row set
1056 | * is created and the current row is set to be the first row in the row set. The current
1057 | * row is set using the sqlany_set_rowset_pos() function.
1058 | *
1059 | * For A_BINARY and A_STRING * data types,
1060 | * value->buffer points to an internal buffer associated with the result set.
1061 | * Do not rely upon or alter the content of the pointer buffer as it changes when a
1062 | * new row is fetched or when the result set object is freed. Users should copy the
1063 | * data out of those pointers into their own buffers.
1064 | *
1065 | * The value->length field indicates the number of valid characters that
1066 | * value->buffer points to. The data returned in value->buffer is not
1067 | * null-terminated. This function fetches all the returned values from the SQL
1068 | * Anywhere database server. For example, if the column contains
1069 | * a blob, this function attempts to allocate enough memory to hold that value.
1070 | * If you do not want to allocate memory, use sqlany_get_data() instead.
1071 | *
1072 | * \param sqlany_stmt A statement object executed by
1073 | * sqlany_execute() or sqlany_execute_direct().
1074 | * \param col_index The number of the column to be retrieved.
1075 | * The column number is between 0 and sqlany_num_cols() - 1.
1076 | * \param buffer An a_sqlany_data_value object to be filled with the data fetched for column col_index at the current row in the row set.
1077 | * \return 1 on success or 0 for failure. A failure can happen if any of the parameters are invalid or if there is
1078 | * not enough memory to retrieve the full value from the SQL Anywhere database server.
1079 | * \sa sqlany_execute_direct(), sqlany_execute(), sqlany_fetch_absolute(), sqlany_fetch_next(), sqlany_set_rowset_pos()
1080 | */
1081 | sacapi_bool sqlany_get_column( a_sqlany_stmt * sqlany_stmt, sacapi_u32 col_index, a_sqlany_data_value * buffer );
1082 |
1083 | /** Retrieves the data fetched for the specified column at the current row into the supplied buffer memory.
1084 | *
1085 | * When a sqlany_fetch_absolute() or sqlany_fetch_next() function is executed, a row set
1086 | * is created and the current row is set to be the first row in the row set. The current
1087 | * row is set using the sqlany_set_rowset_pos() function.
1088 | *
1089 | * \param sqlany_stmt A statement object executed by
1090 | * sqlany_execute() or sqlany_execute_direct().
1091 | * \param col_index The number of the column to be retrieved.
1092 | * The column number is between 0 and sqlany_num_cols() - 1.
1093 | * \param offset The starting offset of the data to get.
1094 | * \param buffer A buffer to be filled with the contents of the column at the current row in the row set. The buffer pointer must be aligned correctly
1095 | * for the data type copied into it.
1096 | * \param size The size of the buffer in bytes. The function fails
1097 | * if you specify a size greater than 2^31 - 1.
1098 | * \return The number of bytes successfully copied into the supplied buffer.
1099 | * This number must not exceed 2^31 - 1.
1100 | * 0 indicates that no data remains to be copied. -1 indicates a failure.
1101 | * \sa sqlany_execute(), sqlany_execute_direct(), sqlany_fetch_absolute(), sqlany_fetch_next(), sqlany_set_rowset_pos()
1102 | */
1103 | sacapi_i32 sqlany_get_data( a_sqlany_stmt * sqlany_stmt, sacapi_u32 col_index, size_t offset, void * buffer, size_t size );
1104 |
1105 | /** Retrieves information about the fetched data at the current row.
1106 | *
1107 | * When a sqlany_fetch_absolute() or sqlany_fetch_next() function is executed, a row set
1108 | * is created and the current row is set to be the first row in the row set. The current
1109 | * row is set using the sqlany_set_rowset_pos() function.
1110 | *
1111 | * \param sqlany_stmt A statement object executed by
1112 | * sqlany_execute() or sqlany_execute_direct().
1113 | * \param col_index The column number between 0 and sqlany_num_cols() - 1.
1114 | * \param buffer A data info buffer to be filled with the metadata about the data at the current row in the row set.
1115 | * \return 1 on success, and 0 on failure. Failure is returned when any of the supplied parameters are invalid.
1116 | * \sa sqlany_execute(), sqlany_execute_direct(), sqlany_fetch_absolute(), sqlany_fetch_next(), sqlany_set_rowset_pos()
1117 | */
1118 | sacapi_bool sqlany_get_data_info( a_sqlany_stmt * sqlany_stmt, sacapi_u32 col_index, a_sqlany_data_info * buffer );
1119 |
1120 | /** Retrieves column metadata information and fills the a_sqlany_column_info structure with information about the column.
1121 | *
1122 | * \param sqlany_stmt A statement object created by sqlany_prepare() or sqlany_execute_direct().
1123 | * \param col_index The column number between 0 and sqlany_num_cols() - 1.
1124 | * \param buffer A column info structure to be filled with column information.
1125 | * \return 1 on success or 0 if the column index is out of range,
1126 | * or if the statement does not return a result set.
1127 | * \sa sqlany_execute(), sqlany_execute_direct(), sqlany_prepare()
1128 | */
1129 | sacapi_bool sqlany_get_column_info( a_sqlany_stmt * sqlany_stmt, sacapi_u32 col_index, a_sqlany_column_info * buffer );
1130 |
1131 | /** Commits the current transaction.
1132 | *
1133 | * \param sqlany_conn The connection object on which the commit operation is performed.
1134 | * \return 1 when successful or 0 when unsuccessful.
1135 | * \sa sqlany_rollback()
1136 | */
1137 | sacapi_bool sqlany_commit( a_sqlany_connection * sqlany_conn );
1138 |
1139 | /** Rolls back the current transaction.
1140 | *
1141 | * \param sqlany_conn The connection object on which the rollback operation is to be performed.
1142 | * \return 1 on success, 0 otherwise.
1143 | * \sa sqlany_commit()
1144 | */
1145 | sacapi_bool sqlany_rollback( a_sqlany_connection * sqlany_conn );
1146 |
1147 | /** Returns the current client version.
1148 | *
1149 | * This method fills the buffer passed with the major, minor, patch, and build number of the client library.
1150 | * The buffer will be null-terminated.
1151 | *
1152 | * \param buffer The buffer to be filled with the client version string.
1153 | * \param len The length of the buffer supplied.
1154 | * \return 1 when successful or 0 when unsuccessful.
1155 | */
1156 | sacapi_bool sqlany_client_version( char * buffer, size_t len );
1157 | #if _SACAPI_VERSION+0 >= SQLANY_API_VERSION_2
1158 | /** Returns the current client version.
1159 | *
1160 | * This method fills the buffer passed with the major, minor, patch, and build number of the client library.
1161 | * The buffer will be null-terminated.
1162 | *
1163 | * \param context The object that was created with sqlany_init_ex().
1164 | * \param buffer The buffer to be filled with the client version string.
1165 | * \param len The length of the buffer supplied.
1166 | * \return 1 when successful or 0 when unsuccessful.
1167 | * \sa sqlany_init_ex()
1168 | */
1169 | sacapi_bool sqlany_client_version_ex( a_sqlany_interface_context *context, char *buffer, size_t len );
1170 | #endif
1171 |
1172 | /** Retrieves the last error code and message stored in the connection object.
1173 | *
1174 | * \param sqlany_conn A connection object returned from sqlany_new_connection().
1175 | * \param buffer A buffer to be filled with the error message.
1176 | * \param size The size of the supplied buffer.
1177 | * \return The last error code. Positive values are warnings, negative values are errors, and 0 indicates success.
1178 | * \sa sqlany_connect()
1179 | */
1180 | sacapi_i32 sqlany_error( a_sqlany_connection * sqlany_conn, char * buffer, size_t size );
1181 |
1182 | /** Retrieves the current SQLSTATE.
1183 | *
1184 | * \param sqlany_conn A connection object returned from sqlany_new_connection().
1185 | * \param buffer A buffer to be filled with the current 5-character SQLSTATE.
1186 | * \param size The buffer size.
1187 | * \return The number of bytes copied into the buffer.
1188 | * \sa sqlany_error()
1189 | */
1190 | size_t sqlany_sqlstate( a_sqlany_connection * sqlany_conn, char * buffer, size_t size );
1191 |
1192 | /** Clears the last stored error code
1193 | *
1194 | * \param sqlany_conn A connection object returned from sqlany_new_connection().
1195 | * \sa sqlany_new_connection()
1196 | */
1197 | void sqlany_clear_error( a_sqlany_connection * sqlany_conn );
1198 |
1199 | #if _SACAPI_VERSION+0 >= SQLANY_API_VERSION_3
1200 | /** Register a callback routine.
1201 | *
1202 | * This function can be used to register callback functions.
1203 | *
1204 | * A callback type can be any one of the following:
1205 | *
1237 | * \param sqlany_conn A connection object with a connection established using sqlany_connect().
1238 | * \param index Any of the callback types listed below.
1239 | * \param callback Address of the callback routine.
1240 | * \return 1 when successful or 0 when unsuccessful.
1241 | */
1242 | sacapi_bool sqlany_register_callback( a_sqlany_connection * sqlany_conn, a_sqlany_callback_type index, SQLANY_CALLBACK_PARM callback );
1243 | #endif
1244 |
1245 | #if defined(__cplusplus)
1246 | }
1247 | #endif
1248 |
1249 | /** \example examples\connecting.cpp
1250 | * This is an example of how to create a connection object and connect with it to SQL Anywhere.
1251 | */
1252 |
1253 | /** \example examples\fetching_a_result_set.cpp
1254 | * This example shows how to fetch data from a result set.
1255 | */
1256 |
1257 | /** \example examples\preparing_statements.cpp
1258 | * This example shows how to prepare and execute a statement.
1259 | */
1260 |
1261 | /** \example examples\fetching_multiple_from_sp.cpp
1262 | * This example shows how to fetch multiple result sets from a stored procedure.
1263 | */
1264 |
1265 | /** \example examples\send_retrieve_part_blob.cpp
1266 | * This example shows how to insert a blob in chunks and retrieve it in chunks too.
1267 | */
1268 |
1269 | /** \example examples\send_retrieve_full_blob.cpp
1270 | * This example shows how to insert and retrieve a blob in one chunk .
1271 | */
1272 |
1273 | /** \example examples\dbcapi_isql.cpp
1274 | * This example shows how to write an ISQL application using dbcapi.
1275 | */
1276 |
1277 | /** \example examples\callback.cpp
1278 | * This is an example of how to register and use a callback function.
1279 | */
1280 |
1281 | #endif
1282 |
--------------------------------------------------------------------------------
/src/h/sacapidll.h:
--------------------------------------------------------------------------------
1 | // ***************************************************************************
2 | // Copyright (c) 2021 SAP SE or an SAP affiliate company. All rights reserved.
3 | // ***************************************************************************
4 | //
5 | // Licensed under the Apache License, Version 2.0 (the "License");
6 | // you may not use this file except in compliance with the License.
7 | // You may obtain a copy of the License at
8 | //
9 | // http://www.apache.org/licenses/LICENSE-2.0
10 | //
11 | // Unless required by applicable law or agreed to in writing, software
12 | // distributed under the License is distributed on an "AS IS" BASIS,
13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | //
15 | // See the License for the specific language governing permissions and
16 | // limitations under the License.
17 | //
18 | // While not a requirement of the license, if you do modify this file, we
19 | // would appreciate hearing about it. Please email
20 | // sqlany_interfaces@sap.com
21 | //
22 | // ***************************************************************************
23 |
24 | #ifndef SACAPIDLL_H
25 | #define SACAPIDLL_H
26 |
27 | #include "sacapi.h"
28 |
29 | /** \file sacapidll.h
30 | * \brief Header file for stub that can dynamically load the main API DLL.
31 | * The user will need to include sacapidll.h in their source files and compile in sacapidll.c
32 | */
33 |
34 |
35 | #if defined( __cplusplus )
36 | extern "C" {
37 | #endif
38 | typedef sacapi_bool (*sqlany_init_func)( const char * app_name, sacapi_u32 api_version, sacapi_u32 * max_version );
39 | typedef void (*sqlany_fini_func)();
40 | typedef a_sqlany_connection * (*sqlany_new_connection_func)( );
41 | typedef void (*sqlany_free_connection_func)( a_sqlany_connection *sqlany_conn );
42 | typedef a_sqlany_connection * (*sqlany_make_connection_func)( void * arg );
43 | typedef sacapi_bool (*sqlany_connect_func)( a_sqlany_connection * sqlany_conn, const char * str );
44 | typedef sacapi_bool (*sqlany_disconnect_func)( a_sqlany_connection * sqlany_conn );
45 | typedef sacapi_bool (*sqlany_execute_immediate_func)( a_sqlany_connection * sqlany_conn, const char * sql );
46 | typedef a_sqlany_stmt * (*sqlany_prepare_func)( a_sqlany_connection * sqlany_conn, const char * sql_str );
47 | typedef void (*sqlany_free_stmt_func)( a_sqlany_stmt * sqlany_stmt );
48 | typedef sacapi_i32 (*sqlany_num_params_func)( a_sqlany_stmt * sqlany_stmt );
49 | typedef sacapi_bool (*sqlany_describe_bind_param_func)( a_sqlany_stmt * sqlany_stmt, sacapi_u32 index, a_sqlany_bind_param * params );
50 | typedef sacapi_bool (*sqlany_bind_param_func)( a_sqlany_stmt * sqlany_stmt, sacapi_u32 index, a_sqlany_bind_param * params );
51 | typedef sacapi_bool (*sqlany_send_param_data_func)( a_sqlany_stmt * sqlany_stmt, sacapi_u32 index, char * buffer, size_t size );
52 | typedef sacapi_bool (*sqlany_reset_func)( a_sqlany_stmt * sqlany_stmt );
53 | typedef sacapi_bool (*sqlany_get_bind_param_info_func)( a_sqlany_stmt * sqlany_stmt, sacapi_u32 index, a_sqlany_bind_param_info * info );
54 | typedef sacapi_bool (*sqlany_execute_func)( a_sqlany_stmt * sqlany_stmt );
55 | typedef a_sqlany_stmt * (*sqlany_execute_direct_func)( a_sqlany_connection * sqlany_conn, const char * sql_str );
56 | typedef sacapi_bool (*sqlany_fetch_absolute_func)( a_sqlany_stmt * sqlany_result, sacapi_i32 row_num );
57 | typedef sacapi_bool (*sqlany_fetch_next_func)( a_sqlany_stmt * sqlany_stmt );
58 | typedef sacapi_bool (*sqlany_get_next_result_func)( a_sqlany_stmt * sqlany_stmt );
59 | typedef sacapi_i32 (*sqlany_affected_rows_func)( a_sqlany_stmt * sqlany_stmt );
60 | typedef sacapi_i32 (*sqlany_num_cols_func)( a_sqlany_stmt * sqlany_stmt );
61 | typedef sacapi_i32 (*sqlany_num_rows_func)( a_sqlany_stmt * sqlany_stmt );
62 | typedef sacapi_bool (*sqlany_get_column_func)( a_sqlany_stmt * sqlany_stmt, sacapi_u32 col_index, a_sqlany_data_value * buffer );
63 | typedef sacapi_i32 (*sqlany_get_data_func)( a_sqlany_stmt * sqlany_stmt, sacapi_u32 col_index, size_t offset, void * buffer, size_t size );
64 | typedef sacapi_bool (*sqlany_get_data_info_func)( a_sqlany_stmt * sqlany_stmt, sacapi_u32 col_index, a_sqlany_data_info * buffer );
65 | typedef sacapi_bool (*sqlany_get_column_info_func)( a_sqlany_stmt * sqlany_stmt, sacapi_u32 col_index, a_sqlany_column_info * buffer );
66 | typedef sacapi_bool (*sqlany_commit_func)( a_sqlany_connection * sqlany_conn );
67 | typedef sacapi_bool (*sqlany_rollback_func)( a_sqlany_connection * sqlany_conn );
68 | typedef sacapi_bool (*sqlany_client_version_func)( char * buffer, size_t len );
69 | typedef sacapi_i32 (*sqlany_error_func)( a_sqlany_connection * sqlany_conn, char * buffer, size_t size );
70 | typedef size_t (*sqlany_sqlstate_func)( a_sqlany_connection * sqlany_conn, char * buffer, size_t size );
71 | typedef void (*sqlany_clear_error_func)( a_sqlany_connection * sqlany_conn );
72 | #if _SACAPI_VERSION+0 >= SQLANY_API_VERSION_2
73 | typedef a_sqlany_interface_context *(*sqlany_init_ex_func)( const char *app_name, sacapi_u32 api_version, sacapi_u32 *max_version );
74 | typedef void (*sqlany_fini_ex_func)( a_sqlany_interface_context *context );
75 | typedef a_sqlany_connection *(*sqlany_new_connection_ex_func)( a_sqlany_interface_context *context );
76 | typedef a_sqlany_connection *(*sqlany_make_connection_ex_func)( a_sqlany_interface_context *context, void *arg );
77 | typedef sacapi_bool (*sqlany_client_version_ex_func)( a_sqlany_interface_context *context, char *buffer, size_t len );
78 | typedef void (*sqlany_cancel_func)( a_sqlany_connection * sqlany_conn );
79 | #endif
80 | #if _SACAPI_VERSION+0 >= SQLANY_API_VERSION_3
81 | typedef sacapi_bool (*sqlany_register_callback_func)( a_sqlany_connection * sqlany_conn, a_sqlany_callback_type index, SQLANY_CALLBACK_PARM callback );
82 | #endif
83 | #if _SACAPI_VERSION+0 >= SQLANY_API_VERSION_4
84 | typedef sacapi_bool (*sqlany_set_batch_size_func)( a_sqlany_stmt * sqlany_stmt, sacapi_u32 num_rows );
85 | typedef sacapi_bool (*sqlany_set_param_bind_type_func)( a_sqlany_stmt * sqlany_stmt, size_t row_size );
86 | typedef sacapi_u32 (*sqlany_get_batch_size_func)( a_sqlany_stmt * sqlany_stmt );
87 | typedef sacapi_bool (*sqlany_set_rowset_size_func)( a_sqlany_stmt * sqlany_stmt, sacapi_u32 num_rows );
88 | typedef sacapi_u32 (*sqlany_get_rowset_size_func)( a_sqlany_stmt * sqlany_stmt );
89 | typedef sacapi_bool (*sqlany_set_column_bind_type_func)( a_sqlany_stmt * sqlany_stmt, size_t row_size );
90 | typedef sacapi_bool (*sqlany_bind_column_func)( a_sqlany_stmt * sqlany_stmt, sacapi_u32 index, a_sqlany_data_value * value );
91 | typedef sacapi_bool (*sqlany_clear_column_bindings_func)( a_sqlany_stmt * sqlany_stmt );
92 | typedef sacapi_i32 (*sqlany_fetched_rows_func)( a_sqlany_stmt * sqlany_stmt );
93 | typedef sacapi_bool (*sqlany_set_rowset_pos_func)( a_sqlany_stmt * sqlany_stmt, sacapi_u32 row_num );
94 | #endif
95 | #if _SACAPI_VERSION+0 >= SQLANY_API_VERSION_5
96 | typedef sacapi_bool (*sqlany_reset_param_data_func)( a_sqlany_stmt * sqlany_stmt, sacapi_u32 index );
97 | typedef size_t (*sqlany_error_length_func)( a_sqlany_connection * conn );
98 | #endif
99 |
100 | #if defined( __cplusplus )
101 | }
102 | #endif
103 |
104 | /// @internal
105 | #define function( x ) x ## _func x
106 |
107 | /** The SQL Anywhere C API interface structure.
108 | *
109 | * Only one instance of this structure is required in your application environment. This structure
110 | * is initialized by the sqlany_initialize_interface method. It attempts to load the SQL Anywhere C
111 | * API DLL or shared object dynamically and looks up all the entry points of the DLL. The fields in
112 | * the SQLAnywhereInterface structure is populated to point to the corresponding functions in the DLL.
113 | * \sa sqlany_initialize_interface()
114 | */
115 | typedef struct SQLAnywhereInterface {
116 | /** DLL handle.
117 | */
118 | void * dll_handle;
119 |
120 | /** Flag to know if initialized or not.
121 | */
122 | int initialized;
123 |
124 | /** Pointer to ::sqlany_init() function.
125 | */
126 | function( sqlany_init );
127 |
128 | /** Pointer to ::sqlany_fini() function.
129 | */
130 | function( sqlany_fini );
131 |
132 | /** Pointer to ::sqlany_new_connection() function.
133 | */
134 | function( sqlany_new_connection );
135 |
136 | /** Pointer to ::sqlany_free_connection() function.
137 | */
138 | function( sqlany_free_connection );
139 |
140 | /** Pointer to ::sqlany_make_connection() function.
141 | */
142 | function( sqlany_make_connection );
143 |
144 | /** Pointer to ::sqlany_connect() function.
145 | */
146 | function( sqlany_connect );
147 |
148 | /** Pointer to ::sqlany_disconnect() function.
149 | */
150 | function( sqlany_disconnect );
151 |
152 | /** Pointer to ::sqlany_execute_immediate() function.
153 | */
154 | function( sqlany_execute_immediate );
155 |
156 | /** Pointer to ::sqlany_prepare() function.
157 | */
158 | function( sqlany_prepare );
159 |
160 | /** Pointer to ::sqlany_free_stmt() function.
161 | */
162 | function( sqlany_free_stmt );
163 |
164 | /** Pointer to ::sqlany_num_params() function.
165 | */
166 | function( sqlany_num_params );
167 |
168 | /** Pointer to ::sqlany_describe_bind_param() function.
169 | */
170 | function( sqlany_describe_bind_param );
171 |
172 | /** Pointer to ::sqlany_bind_param() function.
173 | */
174 | function( sqlany_bind_param );
175 |
176 | /** Pointer to ::sqlany_send_param_data() function.
177 | */
178 | function( sqlany_send_param_data );
179 |
180 | /** Pointer to ::sqlany_reset() function.
181 | */
182 | function( sqlany_reset );
183 |
184 | /** Pointer to ::sqlany_get_bind_param_info() function.
185 | */
186 | function( sqlany_get_bind_param_info );
187 |
188 | /** Pointer to ::sqlany_execute() function.
189 | */
190 | function( sqlany_execute );
191 |
192 | /** Pointer to ::sqlany_execute_direct() function.
193 | */
194 | function( sqlany_execute_direct );
195 |
196 | /** Pointer to ::sqlany_fetch_absolute() function.
197 | */
198 | function( sqlany_fetch_absolute );
199 |
200 | /** Pointer to ::sqlany_fetch_next() function.
201 | */
202 | function( sqlany_fetch_next );
203 |
204 | /** Pointer to ::sqlany_get_next_result() function.
205 | */
206 | function( sqlany_get_next_result );
207 |
208 | /** Pointer to ::sqlany_affected_rows() function.
209 | */
210 | function( sqlany_affected_rows );
211 |
212 | /** Pointer to ::sqlany_num_cols() function.
213 | */
214 | function( sqlany_num_cols );
215 |
216 | /** Pointer to ::sqlany_num_rows() function.
217 | */
218 | function( sqlany_num_rows );
219 |
220 | /** Pointer to ::sqlany_get_column() function.
221 | */
222 | function( sqlany_get_column );
223 |
224 | /** Pointer to ::sqlany_get_data() function.
225 | */
226 | function( sqlany_get_data );
227 |
228 | /** Pointer to ::sqlany_get_data_info() function.
229 | */
230 | function( sqlany_get_data_info );
231 |
232 | /** Pointer to ::sqlany_get_column_info() function.
233 | */
234 | function( sqlany_get_column_info );
235 |
236 | /** Pointer to ::sqlany_commit() function.
237 | */
238 | function( sqlany_commit );
239 |
240 | /** Pointer to ::sqlany_rollback() function.
241 | */
242 | function( sqlany_rollback );
243 |
244 | /** Pointer to ::sqlany_client_version() function.
245 | */
246 | function( sqlany_client_version );
247 |
248 | /** Pointer to ::sqlany_error() function.
249 | */
250 | function( sqlany_error );
251 |
252 | /** Pointer to ::sqlany_sqlstate() function.
253 | */
254 | function( sqlany_sqlstate );
255 |
256 | /** Pointer to ::sqlany_clear_error() function.
257 | */
258 | function( sqlany_clear_error );
259 |
260 | #if _SACAPI_VERSION+0 >= SQLANY_API_VERSION_2
261 | /** Pointer to ::sqlany_init_ex() function.
262 | */
263 | function( sqlany_init_ex );
264 |
265 | /** Pointer to ::sqlany_fini_ex() function.
266 | */
267 | function( sqlany_fini_ex );
268 |
269 | /** Pointer to ::sqlany_new_connection_ex() function.
270 | */
271 | function( sqlany_new_connection_ex );
272 |
273 | /** Pointer to ::sqlany_make_connection_ex() function.
274 | */
275 | function( sqlany_make_connection_ex );
276 |
277 | /** Pointer to ::sqlany_client_version_ex() function.
278 | */
279 | function( sqlany_client_version_ex );
280 |
281 | /** Pointer to ::sqlany_cancel() function.
282 | */
283 | function( sqlany_cancel );
284 | #endif
285 | #if _SACAPI_VERSION+0 >= SQLANY_API_VERSION_3
286 | /** Pointer to ::sqlany_register_callback() function.
287 | */
288 | function( sqlany_register_callback );
289 | #endif
290 | #if _SACAPI_VERSION+0 >= SQLANY_API_VERSION_4
291 | /** Pointer to ::sqlany_set_batch_size() function.
292 | */
293 | function( sqlany_set_batch_size );
294 | /** Pointer to ::sqlany_set_param_bind_type() function.
295 | */
296 | function( sqlany_set_param_bind_type );
297 | /** Pointer to ::sqlany_get_batch_size() function.
298 | */
299 | function( sqlany_get_batch_size );
300 | /** Pointer to ::sqlany_set_rowset_size() function.
301 | */
302 | function( sqlany_set_rowset_size );
303 | /** Pointer to ::sqlany_get_rowset_size() function.
304 | */
305 | function( sqlany_get_rowset_size );
306 | /** Pointer to ::sqlany_set_column_bind_type() function.
307 | */
308 | function( sqlany_set_column_bind_type );
309 | /** Pointer to ::sqlany_bind_column() function.
310 | */
311 | function( sqlany_bind_column );
312 | /** Pointer to ::sqlany_clear_column_bindings() function.
313 | */
314 | function( sqlany_clear_column_bindings );
315 | /** Pointer to ::sqlany_fetched_rows() function.
316 | */
317 | function( sqlany_fetched_rows );
318 | /** Pointer to ::sqlany_set_rowset_pos() function.
319 | */
320 | function( sqlany_set_rowset_pos );
321 | #endif
322 |
323 | #if _SACAPI_VERSION+0 >= SQLANY_API_VERSION_5
324 | /** Pointer to ::sqlany_reset_param_data() function.
325 | */
326 | function( sqlany_reset_param_data );
327 | /** Pointer to ::sqlany_error_length() function.
328 | */
329 | function( sqlany_error_length );
330 | #endif
331 |
332 | } SQLAnywhereInterface;
333 | #undef function
334 |
335 | /** Initializes the SQLAnywhereInterface object and loads the DLL dynamically.
336 | *
337 | * Use the following statement to include the function prototype:
338 | *
339 | *
340 | * \#include "sacapidll.h"
341 | *
342 | *
343 | * This function attempts to load the SQL Anywhere C API DLL dynamically and looks up all
344 | * the entry points of the DLL. The fields in the SQLAnywhereInterface structure are
345 | * populated to point to the corresponding functions in the DLL. If the optional path argument
346 | * is NULL, the environment variable SQLANY_API_DLL is checked. If the variable is set,
347 | * the library attempts to load the DLL specified by the environment variable. If that fails,
348 | * the interface attempts to load the DLL directly (this relies on the environment being
349 | * setup correctly).
350 | *
351 | * Examples of how the sqlany_initialize_interface method is used can be found in the
352 | * C API examples in the sdk\\dbcapi\\examples directory of your SQL
353 | * Anywhere installation.
354 | *
355 | * \param api An API structure to initialize.
356 | * \param optional_path_to_dll An optional argument that specifies a path to the SQL Anywhere C API DLL.
357 | * \return 1 on successful initialization, and 0 on failure.
358 | */
359 | int sqlany_initialize_interface( SQLAnywhereInterface * api, const char * optional_path_to_dll );
360 |
361 | /** Unloads the C API DLL library and resets the SQLAnywhereInterface structure.
362 | *
363 | * Use the following statement to include the function prototype:
364 | *
365 | *