IBM solidDB 6.5 Programmer Guide
IBM solidDB 6.5 Programmer Guide
Programmer Guide
SC23-9870-06
Note
Before using this information and the product it supports, read the information in “Notices” on page 307.
Note: Information in this document might have been updated since this document was made available. For the
latest available information, see the IBM solidDB and IBM solidDB Universal Cache V6.5 Information Center at
[Link]
© Oy International Business Machines Ab Ltd. 1993, 2013
Contents
Figures . . . . . . . . . . . . . . vii Processing error messages . . . . . . . . 40
Terminating transactions and connections . . . . 40
Tables . . . . . . . . . . . . . . . ix Constructing an application . . . . . . . . . 41
Testing and debugging an application . . . . . 49
Summary of changes . . . . . . . . . xi
3 Using solidDB JDBC Driver . . . . . 51
What is solidDB JDBC Driver . . . . . . . . 51
About this manual . . . . . . . . . xiii Getting started with solidDB JDBC Driver . . . . 51
Typographic conventions . . . . . . . . . xiii Registering solidDB JDBC Driver . . . . . . 53
Syntax notation conventions . . . . . . . . xiv Connecting to the database . . . . . . . . 54
Special notes about solidDB and JDBC . . . . . 56
1 Introduction to solidDB APIs . . . . . 1 JDBC driver interfaces and methods . . . . . . 56
solidDB ODBC Driver . . . . . . . . . . . 1 solidDB JDBC Driver extensions . . . . . . . 62
Using solidDB ODBC Driver functions. . . . . 2 WebSphere compatibility . . . . . . . . . 63
ODBC API basic application steps . . . . . . 2 Connection timeout in JDBC. . . . . . . . 64
Format of the solidDB connect string . . . . . 3 Non-standard connection properties . . . . . 64
Client-side configuration file . . . . . . . . 5 JDBC 2.0 optional package API support . . . . . 68
ODBC non-standard behavior . . . . . . . 6 JDBC connection pooling . . . . . . . . . 68
solidDB JDBC Driver . . . . . . . . . . . 6 solidDB Connected RowSet Class:
solidDB Application Programming Interface (SA API) 7 SolidJDBCRowSet . . . . . . . . . . . 77
solidDB Server Control API (SSC API) . . . . . . 7 Java Naming and Directory Interface (JNDI) . . 78
Building client applications . . . . . . . . . 7 Code examples . . . . . . . . . . . . . 78
What is a client? . . . . . . . . . . . . 7 solidDB JDBC Driver type conversion matrix . . . 90
How is the query passed to the server? . . . . 7
How are the results passed back to the client? . . 9 4 Using solidDB SA . . . . . . . . . 93
Using the ODBC driver library . . . . . . . 9 What is solidDB SA? . . . . . . . . . . . 93
Statement cache . . . . . . . . . . . . 10 Getting started with solidDB SA . . . . . . . 94
Writing data by using solidDB SA without SQL . . 95
2 Using solidDB ODBC API . . . . . . 11 Reading data by using solidDB SA without SQL . . 97
Installing solidDB ODBC Driver . . . . . . . 11 Running SQL Statements by Using solidDB SA . . 99
solidDB ODBC Driver 3.51 Features Support . . . 12 Transactions and autocommit mode . . . . . . 99
Overview of usage on Windows operating systems 12 Handling database errors . . . . . . . . . 100
Calling functions . . . . . . . . . . . . 13 Special notes about solidDB SA . . . . . . . 101
Connecting to a data source . . . . . . . . . 15 solidDB SA Function Reference . . . . . . . 103
Network name and connect string syntax . . . 16 SaArrayFlush . . . . . . . . . . . . 105
Using logical data source names . . . . . . 18 SaArrayInsert . . . . . . . . . . . . 106
Empty data source name . . . . . . . . . 19 SaColSearchCreate. . . . . . . . . . . 106
Configuring the solidDB ODBC Data Source for SaColSearchFree . . . . . . . . . . . 107
Windows . . . . . . . . . . . . . . 20 SaColSearchNext . . . . . . . . . . . 107
Using solidDB ODBC Driver with unixODBC . . 20 SaConnect . . . . . . . . . . . . . 108
Retrieving user login information . . . . . . 22 SaCursorAscending . . . . . . . . . . 108
ODBC handle validation . . . . . . . . . . 23 SaCursorAtleast . . . . . . . . . . . 109
Executing transactions . . . . . . . . . . . 24 SaCursorAtmost . . . . . . . . . . . 109
Retrieving information about the data source's SaCursorBegin . . . . . . . . . . . . 110
catalog . . . . . . . . . . . . . . . . 26 SaCursorClearConstr . . . . . . . . . . 110
Using ODBC extensions to SQL . . . . . . . 26 SaCursorColData . . . . . . . . . . . 111
Procedures . . . . . . . . . . . . . 26 SaCursorColDate . . . . . . . . . . . 112
Hints . . . . . . . . . . . . . . . 27 SaCursorColDateFormat . . . . . . . . . 113
Additional ODBC extension functions . . . . 28 SaCursorColDfloat. . . . . . . . . . . 113
solidDB Extensions for ODBC API. . . . . . . 29 SaCursorColDouble . . . . . . . . . . 114
Using cursors. . . . . . . . . . . . . . 31 SaCursorColDynData . . . . . . . . . . 115
Assigning storage for rowsets (binding) . . . . 32 SaCursorColDynStr . . . . . . . . . . 116
Cursor support . . . . . . . . . . . . 33 SaCursorColFloat . . . . . . . . . . . 117
Using bookmarks . . . . . . . . . . . . 38 SaCursorColInt . . . . . . . . . . . . 118
Error text format . . . . . . . . . . . . 38 SaCursorColLong . . . . . . . . . . . 119
iii
SaCursorColNullFlag . . . . . . . . . . 119 SaSetTimestampFormat . . . . . . . . . 155
SaCursorColStr . . . . . . . . . . . . 120 SaSQLExecDirect . . . . . . . . . . . 155
SaCursorColTime . . . . . . . . . . . 121 SaTransBegin . . . . . . . . . . . . 156
SaCursorColTimestamp . . . . . . . . . 122 SaTransCommit . . . . . . . . . . . 156
SaCursorCreate . . . . . . . . . . . . 122 SaTransRollback . . . . . . . . . . . 157
SaCursorDelete . . . . . . . . . . . . 123 SaUserId . . . . . . . . . . . . . . 157
SaCursorDescending . . . . . . . . . . 123
SaCursorEnd . . . . . . . . . . . . 124 5 Using Unicode . . . . . . . . . . 159
SaCursorEqual . . . . . . . . . . . . 124 What is Unicode? . . . . . . . . . . . . 160
SaCursorErrorInfo . . . . . . . . . . . 125 Designing Unicode databases . . . . . . . . 161
SaCursorFree . . . . . . . . . . . . 125 Using solidDB tools with Unicode . . . . . . 163
SaCursorInsert . . . . . . . . . . . . 126 Compatibility between Unicode and partial
SaCursorLike . . . . . . . . . . . . 126 Unicode databases. . . . . . . . . . . . 164
SaCursorNext . . . . . . . . . . . . 127 Converting partial Unicode databases to
SaCursorOpen . . . . . . . . . . . . 127 Unicode . . . . . . . . . . . . . . 164
SaCursorOrderbyVector . . . . . . . . . 127 Developing applications for Unicode . . . . . 166
SaCursorPrev . . . . . . . . . . . . 128 ODBC applications and Unicode databases . . 167
SaCursorReSearch . . . . . . . . . . . 129 JDBC applications and Unicode databases . . . 169
SaCursorSearch. . . . . . . . . . . . 129
SaCursorSearchByRowid . . . . . . . . 130
6 Using Transaction Log Reader . . . 171
SaCursorSearchReset . . . . . . . . . . 130
Considerations for developing applications with
SaCursorSetLockMode . . . . . . . . . 132
Log Reader . . . . . . . . . . . . . . 171
SaCursorSetPosition . . . . . . . . . . 133
Configuring the Log Reader . . . . . . . . 173
SaCursorSetRowsPerMessage . . . . . . . 134
Reading log data with the Log Reader . . . . . 174
SaCursorUpdate . . . . . . . . . . . 134
Partitioning and filtering log records . . . . . 175
SaDateCreate . . . . . . . . . . . . 135
Creating and deleting partitions . . . . . . 175
SaDateFree . . . . . . . . . . . . . 135
Using partition filters. . . . . . . . . . 175
SaDateSetAsciiz . . . . . . . . . . . 135
Setting transaction batches . . . . . . . . . 176
SaDateSetTimet . . . . . . . . . . . . 136
SaDateToAsciiz . . . . . . . . . . . . 137
SaDateToTimet . . . . . . . . . . . . 138 Appendix A. solidDB supported ODBC
SaDefineChSet . . . . . . . . . . . . 138 functions . . . . . . . . . . . . . 177
SaDfloatCmp . . . . . . . . . . . . 139
SaDfloatDiff . . . . . . . . . . . . . 139 Appendix B. solidDB ODBC Driver
SaDfloatOverflow . . . . . . . . . . . 140 3.5.1 attributes support . . . . . . . 187
SaDfloatProd . . . . . . . . . . . . 140
SaDfloatQuot . . . . . . . . . . . . 141
SaDfloatSetAsciiz . . . . . . . . . . . 141 Appendix C. SQLSTATE error codes 195
SaDfloatSum . . . . . . . . . . . . 142
SaDfloatToAsciiz . . . . . . . . . . . 142 Appendix D. Minimum SQL grammar
SaDfloatUnderflow . . . . . . . . . . 143 requirements for ODBC . . . . . . . 217
SaDisconnect . . . . . . . . . . . . 143 SQL statements . . . . . . . . . . . . . 217
SaDynDataAppend . . . . . . . . . . 143 Control statements (logical condition) . . . . 218
SaDynDataChLen . . . . . . . . . . . 144 Data type support . . . . . . . . . . . . 219
SaDynDataClear . . . . . . . . . . . 145 Parameter data types . . . . . . . . . . . 220
SaDynDataCreate . . . . . . . . . . . 145 Literals in ODBC . . . . . . . . . . . . 221
SaDynDataFree . . . . . . . . . . . . 146 List of reserved keywords . . . . . . . . . 222
SaDynDataGetData . . . . . . . . . . 146
SaDynDataGetLen . . . . . . . . . . . 147 Appendix E. Data types . . . . . . . 225
SaDynDataMove . . . . . . . . . . . 147
SQL data types . . . . . . . . . . . . . 225
SaDynDataMoveRef . . . . . . . . . . 148
C data types. . . . . . . . . . . . . . 225
SaDynStrAppend . . . . . . . . . . . 149
Data type identifiers . . . . . . . . . . . 226
SaDynStrCreate. . . . . . . . . . . . 150
SQL data types . . . . . . . . . . . . . 226
SaDynStrFree . . . . . . . . . . . . 150
C data types. . . . . . . . . . . . . . 230
SaDynStrMove . . . . . . . . . . . . 150
Numeric literals . . . . . . . . . . . . 235
SaErrorInfo . . . . . . . . . . . . . 151
Overriding default precision and scale for numeric
SaGlobalInit . . . . . . . . . . . . . 152
data types . . . . . . . . . . . . . . 237
SaSetDateFormat . . . . . . . . . . . 152
Data type identifiers and descriptors . . . . . 238
SaSetSortBufSize . . . . . . . . . . . 153
Decimal digits . . . . . . . . . . . . . 239
SaSetSortMaxFiles . . . . . . . . . . . 153
Transfer octet length . . . . . . . . . . . 240
SaSetTimeFormat . . . . . . . . . . . 154
Constraints of the gregorian calendar . . . . . 242
Notices . . . . . . . . . . . . . . 307
Appendix G. Timeout controls . . . . 287
Client timeouts . . . . . . . . . . . . . 287
Contents v
vi IBM solidDB: Programmer Guide
Figures
1. ODBC driver setup . . . . . . . . . . 20 2. ODBC data source administrator . . . . . 23
vii
viii IBM solidDB: Programmer Guide
Tables
1. Typographic conventions . . . . . . . . xiii 54. SaColSearchCreate Parameters . . . . . . 107
2. Syntax notation conventions. . . . . . . xiv 55. SaColSearchNext Parameters . . . . . . 107
3. Connect string options . . . . . . . . . 3 56. SaColSearchNext Return Value . . . . . . 108
4. Connect string options . . . . . . . . . 17 57. SaConnect Parameters . . . . . . . . 108
5. Additional ODBC Extension Functions . . . 29 58. SaConnect Return Value . . . . . . . . 108
6. solidDB-specific ODBC functions to ODBC API 29 59. SaCursorAscending parameters . . . . . 109
7. A Sample Resultset . . . . . . . . . . 35 60. SaCursorAtleast Parameters . . . . . . . 109
8. A sample resultset . . . . . . . . . . 35 61. SaCursorAtmost Parameters . . . . . . 110
9. A sample resultset . . . . . . . . . . 36 62. SaCursorBegin Parameters . . . . . . . 110
10. A Sample Resultset . . . . . . . . . . 36 63. SaCursorClearConstr Parameters . . . . . 110
11. A Sample Resultset . . . . . . . . . . 37 64. SaCursorColData Parameters . . . . . . 112
12. Errors in a Data Source . . . . . . . . 39 65. SaCursorColDate Parameters . . . . . . 112
13. Sample Error Messages . . . . . . . . 39 66. SaCursorColDateFormat parameters . . . . 113
14. SQLSTATE values . . . . . . . . . . 39 67. SaCursorColDfloat Parameters . . . . . . 114
15. Differences to the Standard CallableStatement 68. SaCursorColDouble Parameters . . . . . 114
Interface . . . . . . . . . . . . . 57 69. SaCursorColDynData Parameters . . . . . 116
16. Differences to the Standard Connection 70. SaCursorColDynStr Parameters . . . . . 117
Interface . . . . . . . . . . . . . 58 71. SaCursorColFloat Parameters . . . . . . 117
17. Differences to the Standard PreparedStatement 72. SaCursorColInt Parameters . . . . . . . 118
Interface . . . . . . . . . . . . . 59 73. SaCursorColLong Parameters . . . . . . 119
18. Differences to the Standard ResultSet Interface 60 74. SaCursorColNullFlag Parameters . . . . . 120
19. Differences to the Standard Statement Interface 61 75. SaCursorColStr Parameters . . . . . . . 121
20. Differences to the Standard ResultSet Interface 62 76. SaCursorColTime parameters . . . . . . 121
21. Constructor . . . . . . . . . . . . 69 77. SaCursorColTimestamp parameters . . . . 122
22. Constructor . . . . . . . . . . . . 69 78. SaCursorCreate Parameters . . . . . . . 123
23. setDescription. . . . . . . . . . . . 69 79. Return Value. . . . . . . . . . . . 123
24. getDescription . . . . . . . . . . . 70 80. SaCursorDelete parameters . . . . . . . 123
25. setURL . . . . . . . . . . . . . . 70 81. SaCursorDescending parameters . . . . . 124
26. getURL . . . . . . . . . . . . . . 70 82. SaCursorEnd parameters. . . . . . . . 124
27. setUser . . . . . . . . . . . . . . 71 83. SaCursorEqual parameters . . . . . . . 124
28. getUser . . . . . . . . . . . . . . 71 84. SaCursorErrorInfo parameters . . . . . . 125
29. setPassword . . . . . . . . . . . . 72 85. SaCursorFree parameters. . . . . . . . 125
30. getPassword . . . . . . . . . . . . 72 86. SaCursorInsert parameters . . . . . . . 126
31. setConnectionURL . . . . . . . . . . 72 87. SaCursorLike parameters . . . . . . . 126
32. getConnectionURL . . . . . . . . . . 73 88. SaCursorNext parameters . . . . . . . 127
33. getLoginTimeout . . . . . . . . . . . 73 89. SaCursorOpen parameters . . . . . . . 127
34. getLogWriter . . . . . . . . . . . . 73 90. SaCursorOrderbyVector parameters . . . . 128
35. getPooledConnection . . . . . . . . . 74 91. SaCursorPrev parameters . . . . . . . 129
36. getPooledConnection . . . . . . . . . 74 92. SaCursorReSearch Parameters . . . . . . 129
37. setLoginTimeout . . . . . . . . . . . 74 93. SaCursorSearch parameters . . . . . . . 129
38. setLogWriter . . . . . . . . . . . . 75 94. SaCursorSearchByRowid parameters . . . . 130
39. addConnectionEventListener . . . . . . . 75 95. SaCursorSearchReset Parameters . . . . . 132
40. close . . . . . . . . . . . . . . . 76 96. SaCursorSetLockMode Parameters . . . . 133
41. getConnection. . . . . . . . . . . . 76 97. SaCursorSetPosition parameters . . . . . 133
42. removeConnectionEventListener . . . . . 76 98. SaCursorSetRowsPerMessage parameters 134
43. Java data type to SQL data type conversion 90 99. SaCursorUpdate parameters . . . . . . 134
44. Insert operation steps . . . . . . . . . 95 100. SaDateCreate Return Values. . . . . . . 135
45. Update and delete operation steps . . . . . 96 101. SaDateFree parameters . . . . . . . . 135
46. Query Operation Steps . . . . . . . . . 98 102. SaDateSetAsciiz Parameters . . . . . . . 136
47. solidDB SA Function Return Codes . . . . 100 103. SaDateSetTimet parameters . . . . . . . 137
48. Supported SQL Datatype. . . . . . . . 102 104. SaDateToAsciiz parameters . . . . . . . 137
49. solidDB SA Parameter Usage Types . . . . 104 105. SaDateToTimet parameters . . . . . . . 138
50. Return Usage Types for Pointers . . . . . 105 106. SaDefineChSet parameters . . . . . . . 138
51. SaArrayFlush Parameters . . . . . . . 105 107. SaDfloatCmp parameters. . . . . . . . 139
52. SaArrayInsert Parameters . . . . . . . 106 108. SaDfloatDiff parameters . . . . . . . . 139
53. SaColSearchCreate Parameters . . . . . . 107 109. SaDfloatOverflow parameters . . . . . . 140
ix
110. SaDfloatProd Parameters. . . . . . . . 140 160. ODBC Functions' Return Parameter . . . . 239
111. SaDfloatQuot parameters . . . . . . . 141 161. SQL data type decimal digits . . . . . . 240
112. SaDfloatSetAsciiz parameters . . . . . . 141 162. Descriptor field corresponding to decimal
113. SaDfloatSum parameters . . . . . . . . 142 digits . . . . . . . . . . . . . . 240
114. SaDfloatToAsciiz parameters . . . . . . 142 163. ODBC Functions' Return parameter Decimal
115. SaDfloatUnderflow parameters. . . . . . 143 Attributes . . . . . . . . . . . . . 241
116. SaDisconnect Parameters. . . . . . . . 143 164. Transfer Octet Lengths . . . . . . . . 241
117. SaDynDataAppend parameters . . . . . 144 165. Constraints of the Gregorian Calendar 242
118. SaDynDataChLen Parameters . . . . . . 144 166. C Data Type — SQL_C_datatype where
119. SaDynDataClear Parameters . . . . . . 145 Datatype Is: . . . . . . . . . . . . 244
120. SaDynDataCreate Return Value . . . . . 146 167. Character SQL Data to ODBC C Data Types 246
121. SaDynDataFree parameters . . . . . . . 146 168. SQL Data to ODBC C Data Types . . . . . 249
122. SaDynDataGetData parameters . . . . . 146 169. Binary SQL Data to ODBC C Data Types 251
123. SaDynDataGetData Parameters . . . . . 147 170. Date SQL Data to ODBC C Data Types 252
124. SaDynDataMove Parameters . . . . . . 148 171. Time SQL Data to ODBC C Data Types 253
125. SaDynDataMoveRef Parameters . . . . . 149 172. Timestamp SQL Data to ODBC C Data Types 254
126. SaDynStrAppend parameters . . . . . . 149 173. SQL to C Data Conversion Examples 255
127. SaDynStrCreate Return Value . . . . . . 150 174. SQL Data Type — SQL_datatype where
128. SaDynStrFree parameters . . . . . . . 150 Datatype Is: . . . . . . . . . . . . 257
129. SaDynStrMove Parameters . . . . . . . 151 175. C Character Data to ODBC SQL Data Types 259
130. SaErrorInfo Parameters . . . . . . . . 151 176. Numeric C Data to ODBC SQL Data Types 263
131. SaSetDateFormat Parameters . . . . . . 152 177. Bit C Data to ODBC SQL Data Types 264
132. SaSetSortBufSize Parameters . . . . . . 153 178. Binary C Data to ODBC SQL Data Types 265
133. SaSetSortMaxFiles parameters . . . . . . 154 179. Date C Data to ODBC SQL Data Types 266
134. SaSetTimeFormat Parameters . . . . . . 154 180. Time C Data to ODBC SQL Data Types 267
135. SaSetTimestampFormat parameters . . . . 155 181. Timestamp C Data to ODBC SQL Data Ttypes 268
136. SaSQLExecDirect Parameters . . . . . . 155 182. C Data to SQL Data . . . . . . . . . 269
137. SaTransBegin parameters. . . . . . . . 156 183. String Function Arguments . . . . . . . 272
138. SaTransCommit Parameters . . . . . . . 157 184. List of String Functions . . . . . . . . 272
139. SaTransRollback Parameters. . . . . . . 157 185. Numeric Function Arguments . . . . . . 275
140. SaUserId Parameters . . . . . . . . . 157 186. List of Numeric Functions . . . . . . . 276
141. Command line options for solidDB tools for 187. Time and Data Arguments . . . . . . . 278
partial Unicode and Unicode databases . . . 164 188. List of Time and Date Functions . . . . . 278
142. solidDB supported ODBC functions . . . . 177 189. System Function Arguments . . . . . . 283
143. 001 Environment Level . . . . . . . . 187 190. List of System Functions . . . . . . . . 283
144. 002 Connection Level . . . . . . . . . 188 191. Login timeouts . . . . . . . . . . . 287
145. 03 Statement Level . . . . . . . . . . 189 192. Connection timeout . . . . . . . . . 288
146. 04 Column Attributes . . . . . . . . . 192 193. Query Timeout . . . . . . . . . . . 290
147. Error code class values . . . . . . . . 195 194. SQL statement execution timeouts . . . . 291
148. SQLSTATE codes . . . . . . . . . . 195 195. Lock wait timeout . . . . . . . . . . 291
149. Control Statements. . . . . . . . . . 218 196. Optimistic lock wait timeout . . . . . . 292
150. Determining Data Ttype for Several Types of 197. Table lock wait timeout . . . . . . . . 292
Parameters . . . . . . . . . . . . 220 198. Transaction Idle Timeout . . . . . . . . 293
151. List of Reserved Keywords . . . . . . . 222 199. connection idle timeout . . . . . . . . 293
152. Common SQL Data Type Names, Ranges, and 200. Connect timeout . . . . . . . . . . 294
Limits . . . . . . . . . . . . . . 227 201. Ping timeout . . . . . . . . . . . . 294
153. Data types SQLGetTypeInfo returns (1) 229 202. Transparent connection timeout . . . . . 294
154. Data Types SQLGetTypeInfo Returns (2) 229 203. Client parameters . . . . . . . . . . 296
155. Data Types SQLGetTypeInfo Returns (3) 229 204. Communication parameters . . . . . . . 297
156. C vs ODBC Naming Correspondence 231 205. Data Sources parameters . . . . . . . . 298
157. Conversions Involving Numeric Literals 235 206. Shared memory access parameters
158. Override Default Precision and Scale Values (client-side) . . . . . . . . . . . . 298
for Numeric Data Type . . . . . . . . 237 207. TransparentFailover parameters . . . . . 299
159. Concise Type Identifier, Verbose Identifier,
and Type Subcode for Each Datetime . . . 238
xi
v Information on the precision implementation in the functions CURRENT_TIME,
CURTIME, CURRENT_TIMESTAMP, and NOW updated in section Time and
date functions; a milliseconds precision can be defined as an argument (0-6).
v Section Developing applications for Unicode updated: the [Link]=yes
parameter setting is not effective in Unicode databases; blank characters in
CHAR values are always discarded.
v Section Client timeouts updated: the behaviour of client connection timeouts has
changed. If the client can detect reliably that the server is not reachable,
SQLConnect returns immediately, regardless of the timeout setting specified
with, for example, SQL_ATTR_LOGIN_TIMEOUT. This can happen, for
example, if the server is expected to run on the same host, and the client detects
that the server is not running.
v New JDBC connection properties "solid_catalog" and "solid_schema" added in
section Non-standard connection properties.
v The following Optimizer hints have been added in section Hints:
– TRIPLE MERGE JOIN
– UNION FOR OR
– OR FOR OR
– LOOP FOR OR
v Transaction Log Reader usage instructions updated in section Reading log data
with the Log Reader.
solidDB ODBC Driver, solidDB Light Client, and solidDB JDBC Driver help your
client application access solidDB.
v The solidDB ODBC Driver conforms to the Microsoft ODBC 3.51 API standard.
v The solidDB Light Client is a lightweight version of the solidDB ODBC API and
is intended for environments where the footprint of the client application must
be very small.
v The solidDB JDBC Driver is a solidDB implementation of the JDBC 2.0 standard.
This guide assumes general knowledge of relational databases and SQL. It also
assumes familiarity with solidDB. If you will use the ODBC driver, this manual
assumes a working knowledge of the C programming language. If you will use the
JDBC driver, this manual assumes a working knowledge of the Java™
programming language.
Typographic conventions
solidDB documentation uses the following typographic conventions:
Table 1. Typographic conventions
Format Used for
NOT NULL Uppercase letters on this font indicate SQL keywords and
macro names.
xiii
Table 1. Typographic conventions (continued)
Format Used for
File path presentation Unless otherwise indicated, file paths are presented in the
UNIX format. The slash (/) character represents the
installation root directory.
.
. A column of three dots indicates continuation of previous
. lines of code.
Multiple ways exist to raise the abstraction level from the ODBC/JDBC level. It
can be done either by enabling database access from various (usually higher level
programming or scripting languages, such as Visual Basic, Perl, and PHP) or
enabling database access directly through application level objects that are able to
load or save themselves without the application programmer having to be aware
of database connections, transactions, or even SQL Strings.
The solidDB ODBC Driver is a distributed in the form of a library (a Dynamic Link
Library (DLL) on Windows). ThesolidDB installation package includes two ODBC
drivers: one for Unicode and one for ASCII. The Unicode version is a superset of
the ASCII version; you may use it with either Unicode or ASCII character sets.
The solidDB implementation of the ODBC API supports a rich set of database
access operations sufficient for creating robust database applications, including:
v Allocating and deallocating handles
v Getting and setting attributes
v Opening and closing database connections
v Accessing descriptors
v Executing SQL statements
1
v Accessing schema metadata
v Controlling transactions
v Accessing diagnostic information
The solidDB ODBC API is the native call level interface (CLI) for solidDB
databases. It is a distributed in the form of a library (a Dynamic Link Library
(DLL) on Windows). The solidDB ODBC API is compliant with ANSI X3H2 SQL
CLI standard.
Note that step 2 (executing SQL statements) may be done repeatedly, depending
upon how many SQL statements need to be executed.
Read 2, “Using solidDB ODBC API,” on page 11 for more information about using
these API calls.
The same format of the connect string applies to the [Link] parameter as
well as to the connect string used by solidDB tools or ODBC applications.
where
v options can be any combination of the following:
Table 3. Connect string options
See Network trace facility in the IBM solidDB Administrator Guide for details.
-plevel Pings the server at the given level (0-5). All
Clients can always use the solidDB Ping facility at level 1 (0 is no operation/default).
Levels 2, 3, 4 or 5 may only be used if the server is set to use the Ping facility at least at
the same level.
See Ping facility in the IBM solidDB Administrator Guide for details.
-t Turns on the Network trace facility All
See Network trace facility in the IBM solidDB Administrator Guide for details.
Note:
v The protocol_name and the server_name must match the ones that the server is
using in its network listening name.
v If given at the connection time, the connect string must be enclosed in double
quotation marks.
v All components of the connect string are case insensitive.
Examples
[Com]
Connect=tcp -z -c1000 1315
[Com]
Connect=nmpipe host22 SOLID
solsql "tcp localhost 1315"
solsql "tcp [Link] 1315"
rc = SQLConnect(hdbc, "upipe SOLID", (SWORD)SQL_NTS, "dba", 3, "dba", 3);
rc = SQLDriverConnect(hdbc,
(SQLHWND)NULL,
(SQLCHAR*)"DSN=tcp localhost 1964;UID=dba;PWD=dba",
38,
out_string,
255,
&out_length,
SQL_DRIVER_NOPROMPT);
Related concepts:
Important: In most cases, only solidDB server-side parameters are used when
programming for the solidDB. However, occasionally there is a need to use
client-side parameters. For example, you may want to create an application that
defines no data source, but takes the data source from the connect string in the
client-side configuration file.
Note: In solidDB documentation, references to [Link] file are usually for the
server-side [Link] file.
When the solidDB is started, it attempts to open the configuration file [Link]. If
the file does not exist, solidDB will use the factory values for the parameters. If the
file exists, but a value for a particular parameter is not set in the [Link] file,
solidDB will use a factory value for that parameter. The factory values may
depend on the operating system you are using.
By default, the client looks for the [Link] file in the current working directory,
which is normally the directory from which you started the client. When searching
for the file, the solidDB uses the following precedence (from high to low):
v location specified by the SOLIDDIR environment variable (if this environment
variable is set)
v current working directory
Client-side parameters
Error information
Regardless of the version set by the client, the driver returns error information
based on the ODBC 3.0 specification.
If you try to insert or update one or more data items where one of the items has
SQL_NULL_DATA as the length specifier, no data will be inserted. The column
value will become NULL.
the function will return SQL_ERROR but not Error State "HY092" or message
"Invalid Attribute/Option Identifier".
After linking the table with data types WCHAR, WVARCHAR, and LONG
WVARCHAR, when a user inserts a particular record and then
inserts/updates/deletes another record, the driver shows '#deleted' for the
previous newly added/updated record.
The above mentioned OpenSchema methods are not supported by ADO with any
ODBC Driver. This is a limitation of the Microsoft OLE DB Provider for ODBC.
This is not specific to the solidDB ODBC Driver.
For solidDB JDBC Driver, Java Development Kit (JDK) 1.4.2 or newer is supported.
In order to use JDBC, you have to install the solidDB JDBC Driver. Usage of JDBC
drivers varies depending on your Java development environment.
Instructions and samples for using the solidDB JDBC Driver are located in the
/jdbc subdirectory in the solidDB installation package and in 3, “Using solidDB
JDBC Driver,” on page 51.
The SSA API is provided with the shared memory access (SMA) and linked library
access (LLA) libraries. For more details, see solidDB Server Control API (SSC API) in
the IBM solidDB Shared Memory Access and Linked Library Access User Guide.
What is a client?
A client application, or client for short, is a program that submits requests (SQL
queries) to the server and gets results back from the server.
A client program is separate from the server program. In many cases, the client is
also running on a separate computer. Using shared memory access or linked
library access, you can link the client's code directly to the server's code so that
both run as a single process. For more information, see IBM solidDB Shared Memory
Access and Linked Library Access User Guide.
Since the client is a separate program, it cannot directly call functions in the server.
Instead, it must use a communications protocol (such as TCP/IP or named pipes)
to communicate with the server. Different platforms support different protocols. On
some platforms, you may need to link a specific library file (which supports a
specific protocol) to your application so that your application can communicate
with the server.
"JDBC" stands for "Java DataBase Connectivity". It is based heavily on the ODBC
standard and is essentially "ODBC for Java programs".
There are two major ways to pass specific data values (for example, "Smith, Jane"
to the server. The first way is to simply embed the values as literals in the query.
This can be seen in SQL statements like:
INSERT INTO employees (id, name) VALUES (12, ’Smith, Jane’);
This works well if you have a single statement that you want to execute. There are
times, however, that you may want to execute the same basic statement with
different values. For example, if you want to insert data for 500 employees, you
may not want to compose 500 separate statements such as
INSERT INTO employees (id, name) VALUES (12, ’Smith, Jane’);
INSERT INTO employees (id, name) VALUES (13, ’Jones, Sally’);
...
Instead, you might prefer to compose a single "generic" statement and then pass
specific values for that statement. For example, you might want to compose the
following statement:
INSERT INTO employees (id, name) VALUES (?, ?);
and have the question marks replaced with specific data values. This way you can
easily execute all 500 INSERT statements inside a loop without composing a
unique INSERT statement for each employee. By using parameters, you can specify
different values each time a statement executes. A parameter allows you to specify
a variable that will be used by the client program and the ODBC driver to store
values that the client and server exchange. In essence, you pass a parameter for
each place in the statement where you have a question mark.
Another situation where you might want to use parameters to exchange data
values is when working with data that is difficult to represent as string literals. For
example, if you want to insert a digitized copy of the song "American Pie" into
your database, and you do not want to compose an SQL statement with a literal
that contains a series of hexadecimal numbers to represent that digitized data, then
you can store the digitized data in an array and notify the ODBC driver of the
location of that array.
During the execution phase, the ODBC driver will read the values you have stored
in the parameters and will pass those values to the server to use with the
statement that it has already prepared.
Normally you will perform a loop, fetching one row at a time and reading the data
from the parameters after each fetch.
You will then be able to call the functions that are defined in these libraries. For
details about library names, see the SDK Notes in the solidDB package.
Some library files are static — i.e. they are linked to your client application's
executable program at the time that you do a compile-and-link operation. Other
library files are dynamic - these are stored separately from your executable and are
loaded into memory at the time your program executes.
The advantage of a dynamic library is that on many systems it requires less disk
space (and, on some platforms, less memory space) if more than one client uses
that library. For example, if you have two client applications that each link to a 5
MB static library, you will need not only 5 MB of disk space to store the static
library, but also 10 MB of additional disk space to store both copies of the library
that are linked into the application. However, if you link two client applications to
a dynamic library, no additional copies of that library will be required; each
application does not keep its own copy.
For many libraries, solidDB provides both a static and a dynamic version on some
or all platforms.
Statement cache
Processing of queries is additionally optimized by a built-in statement cache.
The statement cache operates in such a way that the prepare phase is omitted if
the prepared statement is in the cache. If a connection is closed, the statement
cache is purged.
In JDBC, the statement cache size can be dynamically set by using a non-standard
"StatementCache" connection property. For more information, see “Non-standard
connection properties” on page 64.
In general, solidDB conforms to the Microsoft ODBC 3.51 standard. solidDB ODBC
APIs are defined based on the function prototypes provided by Microsoft. This
guide details those areas where solidDB-specific usage applies and where support
for options, data types, and functions differ.
Note: This IBM solidDB Programmer Guide does not contain a full ODBC API
reference. For details on developing applications with ODBC API, refer to the
Microsoft ODBC Programmer's Reference.
solidDB provides two versions of the ODBC driver, one for Unicode and one for
ASCII. The Unicode version is a superset of the ASCII version; you may use it
with either Unicode or ASCII character sets.
Windows
In Linux and UNIX environments, the ODBC driver library files are installed to the
following directories:
v <solidDB installation directory>/bin/: dynamic library files
– sac<platform><version>.sa or sac<platform><version>.so – ANSI
– soc<platform><version>.sa or soc<platform><version>.so – Unicode
v <solidDB installation directory>/lib/: static library files
– [Link] or [Link] – ANSI
– [Link] or [Link] – Unicode
11
Installing ODBC drivers without solidDB installation (Windows)
To install the ODBC drivers without installing solidDB in Linux and UNIX
environments:
1. Install solidDB using the installation program.
2. Copy the ODBC driver library file to your client node.
The files are named [Link] and [Link] (where "VV" indicates the
version number) for the Unicode and ASCII versions, respectively. For example, the
Unicode ODBC driver in version 4.1 is named [Link]. To call the functions
in one of these .DLL files, you must link to a solidDB import library file. For the
solidDB on Windows, this import library file is named [Link]
(Unicode) or [Link] (ASCII). This import library file contains the entry
points to the corresponding solidDB ODBC DLL (for example, [Link]).
Note: The library files have been produced with C++. Other development toolkit
manufacturers' linkers may expect different library file formats. In such cases, the
Import Library utility of the development toolkit should be used to build a library
file that is compatible with your linker.
There are two alternatives to building application programs that use the solidDB
ODBC driver:
1. Using Microsoft ODBC Driver Manager.
Microsoft ODBC software needs to be installed on all client workstations and a
Data Source must be defined using solidDB ODBC Driver. If you use the Driver
Manager, then any application that can use the solidDB ODBC driver will also
work with any other ODBC compliant engine.
2. Using solidDB ODBC driver directly.
Connections are opened directly to a server process without using Microsoft
ODBC Driver Manager. This usually makes embedded deployment of solidDB
easier. However, the application can only use the functions provided by the
solidDB library (that is, solidDB ODBC Driver); the application cannot use the
ODBC functions that are implemented by the Microsoft ODBC Driver Manager
or the Microsoft Cursor library.
solidDB provides some sample programs that can be used either with or without
the Microsoft ODBC Driver Manager. These samples are in subdirectories of the
samples directory in your solidDB installation directory. Below are brief
instructions on how to build and run the provided samples in both of the
alternative ways:
v Building the samples to use ODBC Driver Manager.
1. Create a new application project.
2. Add the C-source file (for example, sqled.c or embed.c) to the project.
3. Make the header files visible to the compiler.
4. Define SS_WINDOWS for the compiler.
5. Compile and link.
6. Make sure that you have installed the solidDB ODBC driver. Also, make sure
that the connection string you intend to use is defined as the ODBC data
source name.
7. Run to connect to a listening solidDB server.
v Building the samples to use solidDB ODBC library directly.
The necessary changes to the ODBC Driver Manager configuration are listed
below.
1. Add solidDB ODBC driver library file ([Link]) to the project.
2. Remove ODBC Driver manager libraries ODBC*.LIB from the default library
list.
3. Compile and link.
4. Now it is possible to connect to data sources bypassing ODBC Driver
Manager. Make sure that the SQL API DLL socw32<VV>.dll (where "VV"
indicates the version number) and the solidDB communication DLLs are
available. Data Sources may be defined in [Link] or in the ODBC
Administration Window.
5. Run the client to connect to a listening solidDB server.
Calling functions
This section provides information about how programs call functions in the ODBC
driver.
If your program calls functions in the ODBC driver, your program must include
the ODBC header files. These files define the ODBC functions, and the data types
and constants that are used with ODBC functions. The header files are not
solidDB-specific; they are standard header files provided by Microsoft. The solidDB
ODBC driver (like any ODBC driver) implements the functions that are specified
in these header files.
ODBC drivers come in two "flavors": ASCII and Unicode. The ASCII driver
supports only ASCII character sets. The Unicode driver supports both the Unicode
and the ASCII character sets.
For details on driver, API, and SQL conformance levels, refer to section
Introduction to ODBC in the Microsoft ODBC Programmer's Reference.
An application may link directly to the solidDB ODBC driver, or the application
may link to an ODBC Driver Manager.
On Windows systems, Microsoft supplies the Driver Manager, and you link to the
Driver Manager import library ([Link]) to gain access to the Driver Manager.
On other platforms, you can link to another vendor's Driver Manager. For
example, on Linux systems, you can use unixODBC.
For basic application steps that occur whenever an application calls an ODBC
function and details on calling ODBC functions, refer to section Introduction to
ODBC in the Microsoft ODBC Programmer's Reference.
Data types
Appendix E, “Data types,” on page 225 provides information about SQL data types
that are supported by solidDB. The header files from Microsoft provide
information about C-language data types used by your client program. To transfer
data between the application program and the database server, you must use
appropriate types. For example, on most 32-bit platforms, the C-language "int" data
type corresponds to the SQL data type "INT". The C-language "float" data type
corresponds to the SQL "REAL" data type.
Scalar functions
Scalar functions return a value for each row. For example, the "absolute value"
scalar function takes a numeric column as an argument and returns the absolute
value of each value in the column. Scalar functions are invoked with the following
ODBC escape sequence:
{fn scalar-function}
For a list of scalar functions and a more complete example of their usage, refer to
Appendix F, “Scalar functions,” on page 271.
solidDB provides the following native scalar functions, which cannot be invoked
using the ODBC escape sequence.
v CURRENT_CATALOG() - returns a WVARCHAR string that contains the current
active catalog name. This name is the same as ODBC scalar function {fn
DATABASE()}.
v LOGIN_CATALOG() - returns a WVARCHAR string that contains the login
catalog for the connected user (currently the login catalog is the same as the
system catalog).
v CURRENT_SCHEMA() - returns a WVARCHAR string that contains the current
active schema name.
When an application calls a function, the driver executes the function and returns a
predefined code. These return codes indicate success, warning, or failure status.
The return codes are:
v SQL_SUCCESS
v SQL_SUCCESS_WITH_INFO
v SQL_NO_DATA_FOUND
v SQL_ERROR
v SQL_INVALID_HANDLE
v SQL_STILL_EXECUTING
v SQL_NEED_DATA
To access the data source, you need to define the solidDB server's network name
which the application will use in a SQLConnect() call (ServerName). The network
name may be given in one of the three following ways:
v Include the network name in the function call directly
v Include the network name in the function call using a logical data source name
mapping
v Give the network name in the function call as an empty string
There are three connectivity types for defining the network name:
v Basic connectivity
v Transparent connectivity
v SMA connectivity
For information about Transparent Connectivity (TC Info), see the sections Using the
Transparent Connectivity and Syntax of the Transparent Connectivity Info in the IBM
solidDB High Availability User Guide.
For information about SMA connectivity, see section Establishing local connections for
SMA in the IBM solidDB Shared Memory Access and Linked Library Access User Guide.
where
v <basic connectivity>::=[<encryption attribute>] <connect string>
<encryption attribute>::=USE_ENCRYPTION=YES|NO
<connect string>::=protocol_name [options] [server_name] [port_number]
For example
USE_ENCRYPTION=YES tcp localhost 1315
v <transparent connectivity>::={[<failure transparency level attribute>]
[<preferred access attribute>] [<encryption attribute>] <connect target
list>} | <cluster info>
For details, see Syntax of the Transparent Connectivity Info in the IBM solidDB High
Availability User Guide
For example
TF=SESSION USE_ENCRYPTION=YES SERVERS=tcp 2315 tcp 1315
v <SMA connection>::= sma <connect string>
<connect string>::=protocol_name [options] [server_name] [port_number]
For example
sma tcp 1315
For more information, see section Establishing local connections for SMA in the
IBM solidDB Shared Memory Access and Linked Library Access User Guide.
By this combination, the client specifies the server it will establish a connection to.
The communication protocol and the server name must match the ones that the
server is using in its network listening name. In addition, most protocols need a
specified host computer name if the client and server are running on different
machines. All components of the client's network name are case insensitive.
where
v options can be any combination of the following:
Table 4. Connect string options
See Network trace facility in the IBM solidDB Administrator Guide for details.
-plevel Pings the server at the given level (0-5). All
Clients can always use the solidDB Ping facility at level 1 (0 is no operation/default).
Levels 2, 3, 4 or 5 may only be used if the server is set to use the Ping facility at least at
the same level.
See Ping facility in the IBM solidDB Administrator Guide for details.
-t Turns on the Network trace facility All
See Network trace facility in the IBM solidDB Administrator Guide for details.
Note:
v The protocol_name and the server_name must match the ones that the server is
using in its network listening name.
The same format of the connect string applies to the [Link] parameter as
well as to the connect string used by solidDB tools or ODBC applications.
Examples
[Com]
Connect=tcp -z -c1000 1315
[Com]
Connect=nmpipe host22 SOLID
solsql "tcp localhost 1315"
solsql "tcp [Link] 1315"
rc = SQLConnect(hdbc, "upipe SOLID", (SWORD)SQL_NTS, "dba", 3, "dba", 3);
rc = SQLDriverConnect(hdbc,
(SQLHWND)NULL,
(SQLCHAR*)"DSN=tcp localhost 1964;UID=dba;PWD=dba",
38,
out_string,
255,
&out_length,
SQL_DRIVER_NOPROMPT);
The logical data source name can be mapped to a data source as a 'logical name'
and 'connect string' (network name) pair in the following ways:
v Using the [Data Sources] section in the client-side [Link] file
The syntax of the parameters is the following:
[Data Sources]
logical_name = connect_string; Description
where Description can be used for comments on the purpose of the logical
name
Example:
To map a logical name My_application to a database that you want to connect
using TCP/IP, include the following lines in the [Link] file:
[Data Sources]
My_application = tcpip irix 1313; Sample data source
When an application calls the data source 'My_application', the solidDB client
maps this to a call to 'tcpip irix 1313'.
v In Windows environments, using the registry settings (ODBC Driver
Manager)
You can use the Control Panel > Administrative Tools > Data Sources (ODBC)
dialog or the Registry Editor (regedit) to add mappings.
For details, see Configuring the solidDB ODBC Data Source for Windows in the IBM
solidDB Programmer Guide.
Tip: The solidDB data management tools use the solidDB ODBC API. If you
have defined an ODBC Data Source, you can use the logical name source name
also when connecting to solidDB server with the solidDB tools.
When connecting to the solidDB server, if the network name is not a valid connect
string, the solidDB tools and clients assume it is a logical data source name. To
find a mapping between the logical data source name and a valid connect string,
the solidDB tools and clients check the client-side [Link] file.
In Windows environments, if the [Link] file is not found or the logical data
source name is not defined in the [Data Sources] section, the data source settings
made with the Windows registry settings are checked in the following order.
1. Look for the Data Source Name from the following registry path:
HKEY_CURRENT_USER\software\odbc\[Link]\DSN
2. Look for the Data Source Name from the following registry path
HKEY_LOCAL_MACHINE\software\odbc\[Link]\DSN
The check for the logical data source mappings might impact performance:
v If the file system is particularly slow, for example, because the working directory
is mapped to a network drive, checking the existence of the [Link] file can
have a measurable performance impact.
v In Windows environments, all logical data source mappings in the ODBC
registry are checked. The time consumed for this operation is proportional to the
amount of defined data sources.
– With only few (1 to 5) data sources, the connection time will be
approximately 5 ms.
– With 1000 data sources, the connection time will be approximately 200 ms.
However, if the [Link] file contains the logical data source name mapping,
the tools and clients do not try to access the ODBC registry for the mapping.
The [Link] file must reside in the current working directory of the application
or in a path specified by the SOLIDDIR environment variable.
The following connect line in the [Link] of the application workstation will
connect an application (client) using the TCP/IP protocol to a solidDB server
running on a host computer named 'spiff' and listening with the name (port
number in this case) '1313'.
[Com]
Connect = tcpip spiff 1313
If the Connect parameter is not found in the [Link] configuration file, then the
client uses the environment-dependent default instead. The defaults for the Listen
and Connect parameters are selected so that the application (client) will always
connect to a local solidDB server listening with a default network name. So local
communication (inside one machine) does not necessarily need a configuration file
for establishing a connection.
To be able to configure solidDB ODBC data sources, the solidDB ODBC Driver
must be installed.
Procedure
1. Invoke Data Sources (ODBC) from Control Panel > Administrative Tools
2. Open the User DSN tab.
3. Click the Add... button.
4. Select the solidDB ODBC Driver (ANSI or UNICODE according to your
database requirements).
5. Enter the Data Source configuration in the solidDB ODBC Driver Setup box as
shown in the following example.
Note: The NetworkName entry should be compliant with the database server
listen addresses defined in [Link]. The network name follows the
connection string format presented in “Format of the solidDB connect string”
on page 3.
The unixODBC DriverManager loads the correct data source driver according to
the specifications in the following two configuration files:
v [Link] or .[Link]: specifies the logical name of the data source and the
actual ODBC driver
The [Link] file defines the system-level settings that are available to all users.
The .[Link] file defines user-level settings.
v [Link]: connects the logical driver name with its physical location in the
file system.
The [Link] is a system-level file.
In addition to the files above, the solidDB ODBC Driver needs a client-side
[Link] configuration file where the logical data source name is connected with
the a valid solidDB connect string.
The logical name and the physical location of the ODBC driver must be specified
in the [Link] file as follows:
v [<the logical name of the driver>], for example, [solid_odbc]
v Driver = <absolute path to the driver>, for example, Driver =
/home/jsmith/[Link]
In the client-side [Link] file, the logical data source name must be connected to
a valid solidDB connect string (network name) as follows:
v [Data Sources]
v <the logical data source name> = <connect_string> , for example,
my_solid=tcp my_machine 1964
If the application calls SQLDriverConnect() and requests that the user be prompted
for information, the Driver Manager displays a dialog box similar to the following
example:
For example, in Windows environments with ODBC driver manager, the driver
manager performs the handle validation and the solidDB ODBC driver does not
need to repeat the same validation procedures. Also, a carefully written ODBC
application does not normally cause invalid handles to be used; in such a case, the
handle validation in the ODBC driver is not needed. In both cases, the applications
can benefit from performance improvements when skipping the handle validation
in the driver.
When the handle validation is switched on, any ODBC function may fail with the
standard return value SQL_INVALID_HANDLE.
If handle validation is turned off and invalid handle is used by the application, the
ODBC driver behavior is unpredictable and most likely causes the application to
crash.
Related concepts:
“solidDB Extensions for ODBC API” on page 29
The following functions and connection attributes are solidDB-specific extensions
to ODBC API.
Appendix H, “Client-side configuration parameters,” on page 295
The client-side configuration parameters are stored in the client-side [Link]
configuration file and are read when the client starts.
Executing transactions
This section provides information about how transactions are committed.
Important:
v When the isolation level is other than READ COMMITTED, even read-only
statements (for example, SELECT) must be committed. Furthermore, the user
must commit SELECT statements even if the server is in autocommit mode.
Failure to commit statements can reduce performance or cause the server to run
out of memory. This is explained in more detail below.
v If the isolation level is READ COMMITTED, read-only statements need not be
committed. In that case, the explanation below does not apply.
Even a read-only statement must be committed. The reason for this is that solidDB
saves the 'read-level' of each transaction and until that transaction commits, all
subsequent transactions from other connections are also maintained in memory.
(This behavior is part of the row versioning performed by the Bonsai Tree
Using autocommit mode does not ensure that SELECT statements are committed.
The server cannot automatically commit SELECTs because SELECTs do not execute
as a single statement. Each SELECT involves opening a cursor, fetching rows, and
then closing the cursor.
There are two possible ways that the server could automatically commit when
fetching multiple rows: the server could commit after the final fetch, or the server
could commit after each individual fetch. Unfortunately, neither of these is
practical, and therefore the server cannot commit the SELECT statement even in
autocommit mode.
The server cannot automatically commit after the final fetch because the server
does not know which fetch is the final fetch — the server does not know how
many rows the user will fetch. (Until the user closes the cursor, the server does not
know that the user is done fetching.)
It is not practical to commit after each individual fetch because each transaction
should see the data as it was at the time that the transaction started, and therefore
if each fetch is in a different transaction then the data can be from a different
"snapshot" of the database. Putting each fetch in a different transaction would also
make REPEATABLE READ and SERIALIZABLE transaction isolation levels
confusing or meaningless for the cursor, even though the cursor is for a single
SELECT statement.
Note: To ensure that the data in the cursor is consistent and recent, the server
actually does an automatic commit immediately prior to opening the cursor (if
autocommit is on). The server then immediately starts a new transaction to contain
the subsequent FETCH statement(s). This new transaction, like any other
transaction, must be committed (or rolled back).
Summary
In most cases when you are doing SELECT statements in autocommit mode, you
should explicitly close each cursor as soon as you are done with it and then
For details on SQL extensions, refer to Escape Sequences in ODBC in the Microsoft
ODBC Programmer's Reference.
Details on solidDB usage for these extensions are described in the following
sections.
Procedures
Stored procedures are procedural program code containing one or more SQL
statements and program logic.
where procedure-name specifies the name of a procedure stored on the data source
and parameter specifies a procedure parameter.
Note: solidDB does not support the optional "?=" included in the ODBC standard:
{[?=] call procedure-name [([parameter][,[parameter]]...)]}
Procedure calls do not require input and input/output parameters; however, the
following rules apply:
v A procedure called with parentheses but with parameters omitted, such as {call
procedure_name()} may cause the procedure to fail.
v A procedure called without parentheses, such as {call procedure_name}, returns no
parameter values.
v Input parameters may be omitted. Omitted input or input/output parameters
cause the driver to instruct the data source to use the default value of the
parameter. As an option, a parameter's default value can be set using the value
of the length/indicator buffer bound to the parameter to
SQL_DEFAULT_PARAM.
v When a parameter is omitted, the comma delimiting it from other parameters
must be present.
v Omitted input/output parameters or literal parameter values cause the driver to
discard the output value.
v Omitted parameter markers for a procedure's return value cause the driver to
discard the return value.
v If an application specifies a return value parameter for a procedure that does not
return a value, the driver sets the value of the length/indicator buffer bound to
the parameter to SQL_NULL_DATA.
For more information about procedures, see Stored procedures in the IBM solidDB
SQL Guide.
Hints
Hints are an extension of SQL that provide directives to the SQL optimizer for
determining the query execution plan that is used. Hints are specified through
embedded pseudo comments within query statements. The optimizer detects these
Hints are needed because due to various conditions with the data, user query, and
database, the SQL optimizer is not always able to choose the best possible
execution plan. For example, you might want to force a merge join because you
know, unlike the optimizer, that your data is already sorted. Also, sometimes
specific predicates in queries can cause performance problems that the optimizer
cannot eliminate. The optimizer may be using an index that you know is not
optimal. In this case, you may want to force the optimizer to use one that produces
faster results.
Hints syntax
hint::=
[MERGE JOIN |
TRIPLE MERGE JOIN |
LOOP JOIN |
JOIN ORDER FIXED |
INTERNAL SORT |
EXTERNAL SORT |
INDEX [REVERSE] table_name.index_name |
PRIMARY KEY [REVERSE] table_name |
FULL SCAN table_name |
[NO] SORT BEFORE GROUP BY |
UNION FOR OR |
OR FOR OR |
LOOP FOR OR]
For more information on the hints syntax, see HINT in the IBM solidDB SQL Guide.
Hints are enabled and disabled using the [Link] parameter. By default,
hints are enabled ([Link]=yes).
Function Description
Function Description
Using cursors
The ODBC Driver uses a cursor concept to keep track of its position in the
resultset, that is, in the data rows retrieved from the database. A cursor is used for
tracking and indicating the current position, as the cursor on a computer screen
indicates current position.
Each time an application calls SQLFetch, the driver moves the cursor to the next
row and returns that row. An application can also call SQLFetchScroll or
SQLExtendedFetch (ODBC 2.x), which fetches more than one row with a single
fetch or call into the application buffer. This is known as "block cursor" support.
Note that the actual number of rows fetched depends upon the rowset size
specified by the application.
The cursor supported by the core ODBC functions only scrolls forward, one row at
a time. (To re-retrieve a row of data that it has already retrieved from the resultset,
the application must close the cursor by calling SQLFreeStmt with the SQL_CLOSE
option, re-execute the SELECT statement, and fetch rows with SQLFetch, SQLFetch
Scroll, or SQLExtendedFetch (ODBC 2.x) until the target row is retrieved.) If you
need the ability to scroll backward as well as forward, use block cursors.
Column-wise binding
Row-wise binding
For example, when balancing financial data, an accountant needs data that appears
static; it is impossible to balance books when the data is continually changing.
When selling concert tickets, a clerk needs up-to-the minute, or dynamic, data on
which tickets are still available.
solidDB cursors which are set with SQLSetStmtAttr as "dynamic" closely resemble
static cursors, with some dynamic behavior. solidDB dynamic cursor behavior is
static in the sense that changes made to the resultset by other users are not visible
to the user, as opposed to ODBC dynamic cursors in which changes are visible to
the user.
In solidDB, as long as the cursor scrolls forward from block to block and never
scrolls backward or the cursors move back and forth within the same block after
an update is done, then the user gets the dynamic cursor behavior. This means that
all changes are visible. Note, however that this behavior is affected by the solidDB
AUTOCOMMIT mode setting. For details, read “Cursors and autocommit” on page
34. For an example of cursor behavior when using SQLSetPos, read “Cursors and
positioned operations” on page 35.
Cursor support
This section describes the cursor type supported by solidDB.
There are also some limitations in using the solidDB Autocommit mode if your
application uses block cursors and positioned updates and deletes. For a brief
description of these cursor features, read “Using cursors” on page 31.
When using block cursors and positioned updates and deletes, you must:
v In the application, set commit mode to SQL_AUTOCOMMIT_OFF.
v Commit changes in the application only when all the fetch and positioned
operations are done.
v In between positioned operations, be sure not to commit the changes.
Attention:
The solidDB ODBC Driver keeps a row number/counter for every row in the
rowset, which is the data rows retrieved from the database. When an application
has the commit mode set to SQL_AUTOCOMMIT_ON and then executes a
positioned update or a delete on a row in the rowset, the row is immediately
updated in the database. Depending on the new value of the row, the row may be
moved from its original position in the resultset. Since the updated row has now
moved and its new position is unpredictable (since it is totally dependent on the
new value), the driver loses the counter for this row.
In addition, the counter for all other rows in the rowset may also become invalid
because of a change in position of the updated row. Hence the application may see
incorrect behavior when it does the next fetch or SQLSetPos operation.
1 Antony
2 Ben
3 Charlie
4 David
5 Edgar
Assume now that the application calls SQLSetPos to update the third row with a
new value of Gerard. To perform the update, the new row value is moved and
positioned as shown below:
Table 8. A sample resultset
1 Antony
2 Ben
Empty row
4 David
5 Edgar
Now the row counter for "David" becomes 3 and not 4, while the counter for
"Edgar" becomes 4 and not 5. Since some row counters are now invalid, they will
give wrong results when used by the driver to do relative or absolute positioning
of the cursor.
If the commit mode had been set to SQL_AUTOCOMMIT_OFF, the database is not
updated until the SQLEndTran function is called to commit the changes.
Case 1 illustrates cursor behavior when using SQLSetPos. In Case 1, the cursor
scrolls back and forth within the same block after the update is applied.
Case 2 shows how cursor behavior is limited using SQLSetPos when the cursor
scrolls backward within a rowset or the cursors move back and forth within a
different rowset after an update is applied.
Case 1
A sample resultset is shown below. In the sample, the resultset has only 1 column
(defined as varchar(32)). In the table below, the first column shows the row
number maintained by the driver internally. The second column shows the actual
row values.
Table 9. A sample resultset
1 Antony
2 Ben
3 Charlie
4 David
5 Edgar
Assume now that the application calls SQLSetPos to update the third and fourth
rows of the resultset with the names Caroline and Debbie. After the updates, the
actual row values now contain Caroline and Debbie, as shown below:
Table 10. A Sample Resultset
1 Antony
2 Ben
3 Caroline
4 Debbie
5 Edgar
Note: In some cases, the resultset for a SELECT statement may be too large to fit
in memory. As the user scrolls back and forth within the resultset, the ODBC
Driver may discard some rows from memory and read in others. This can cause
unexpected results: in some situations, updates to data in the cursor may seem to
"disappear" and then "reappear" if the cursor re-reads (for example, from disk) the
original values for a row that it previously modified.
Case 2
Case 2 shows the limitations when using positioned operations. The following
example shows cursor behavior using positioned operations and shows when
position updates are not visible to users.
1 Antony
2 Ben
3 Charlie
4 David
5 Edgar
6 Fred
7 Gough
8 Harry
9 Ivor
10 John
Assume that after the first 4 steps above, the application calls SQLSetPos to
perform the following tasks:
5. Updates the third row of the resultset.
6. Scrolls to the next rowset by calling SQLFetchScroll. This will get rows 6 to 10
and the cursor will be pointing to row 6.
7. Scrolls backward one rowset to get to the first rowset. This is done by calling
SQLScrollFetch with the FETCH_PRIOR option.
After these tasks are performed, the value of the third row that was updated in
step 5 still has the old value rather than the updated value as in "Case 1". The
updated value is only visible in the Case 2 situation when the change is
committed. But due to the unpredictable behavior when setting
SQL_AUTOCOMMIT_ON as described in section “Positioned Cursor Operations
and SQL_AUTOCOMMIT_ON” on page 34, commits cannot be done until all work
related to block cursors and positioned operations is completed.
Using bookmarks
A bookmark is a 32-bit value that an application uses to return to a row. solidDB
provides no support for bookmarks.
If the source of an error is the component itself, the error message must explain
this. Therefore, the error text returned by SQLError has two different formats: one
for errors that occur in a data source and one for errors that occur in other
components in an ODBC connection.
For errors that do not occur in a data source, the error text must use the format:
[vendor_identifier][ODBC_component_identifier]
component_supplied_text
For errors that occur in a data source, the error text must use the format:
[vendor_identifier][ODBC_component_identifier]
[data_source_identifier] data_source_supplied_text
Element Meaning
Note: The brackets ([ ]) are included in the error text; they do not indicate optional
items.
SQLSTATE values are strings that contain five characters; the first two are a class
value, followed by a three-character subclass value. For example 01000 has 01 as its
class value and 000 as its subclass value. Note that a subclass value of 000 means
there is no subclass for that SQLSTATE. Class and subclass values are defined in
SQL-92.
Table 14. SQLSTATE values
01, 07, 08, 21, 22, 23, 24, 25, Indicates an error that includes a return value of
28, 34, 3C, 3D, 3F, 40, 42, 44, SQL_ERROR.
HY Note: Error class 01 returns both warnings and errors.
Related reference:
Appendix C, “SQLSTATE error codes,” on page 195
This topic contains an error codes table that provides possible SQLSTATE values
that a driver returns for the SQLGetDiagRec function.
The application may parse the error text to separate the text from the information
identifying the source of the error. It is the application's responsibility to take
appropriate action based on the error or provide the user with a choice of actions.
The ODBC interface provides functions that terminate statements, transactions, and
connections, and free statement, connection, and environment handles.
SQLFreeHandle is used to close the cursor if one exists, discard pending results,
and free all resources associated with the statement handle.
Terminating transactions
Constructing an application
This section provides two examples of C-language source code for applications: an
example that uses static SQL functions to create a table, add data to it, and select
the inserted data; and another example of interactive, ad-hoc query processing.
Microsoft provides two types of header files, one for ASCII data and the other for
Unicode data. This example can use either of the Microsoft ODBC header files.
***************************************************************/
#if (defined(SS_UNIX) || defined(SS_LINUX))
#include <solidodbc3.h>
#else
#include <windows.h>
#endif
#include <stdio.h>
#include <test_assert.h>
#define MAX_NAME_LEN 50
#define MAX_STMT_LEN 100
/**************************************************************
Function Name: PrintError
Purpose......: To Display the error associated with
the handle
***************************************************************/
SQLINTEGER PrintError(SQLSMALLINT handleType,SQLHANDLE handle)
{
SQLRETURN rc = SQL_ERROR;
SQLWCHAR sqlState[6];
SQLWCHAR eMsg[SQL_MAX_MESSAGE_LENGTH];
SQLINTEGER nError;
rc = SQLGetDiagRecW(handleType, handle, 1,
(SQLWCHAR *)&sqlState, (SQLINTEGER *)&nError,
(SQLWCHAR *)&eMsg, 255, NULL);
/**************************************************************
Function Name: DrawLine
Purpose : To Draw a specified charcter (chr) for
specified number of times (len)
**************************************************************/
void DrawLine(SQLINTEGER len, SQLCHAR chr)
{
printf("\n");
while(len > 0) {
printf("%c",chr);
len--;
}
printf("\n");
/***************************************************************
Function Name: example1
Purpose : Connect to the specified data source and
execute the set of SQL Statements
***************************************************************/
SQLINTEGER example1(SQLCHAR *server, SQLCHAR *uid, SQLCHAR *pwd)
{
SQLHENV henv;
SQLHDBC hdbc;
SQLHSTMT hstmt;
SQLRETURN rc;
SQLINTEGER id;
SQLWCHAR drop[MAX_STMT_LEN];
SQLCHAR name[MAX_NAME_LEN+1];
SQLWCHAR create[MAX_STMT_LEN];
SQLWCHAR insert[MAX_STMT_LEN];
SQLWCHAR select[MAX_STMT_LEN];
SQLINTEGER namelen;
rc = SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE,
&henv);
if (rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO)
return(PrintError(SQL_HANDLE_ENV,henv));
rc = SQLSetEnvAttr(henv,SQL_ATTR_ODBC_VERSION,
(SQLPOINTER)SQL_OV_ODBC3,SQL_NTS);
if (rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO)
return(PrintError(SQL_HANDLE_ENV, henv));
rc = SQLAllocHandle(SQL_HANDLE_DBC,henv,&hdbc);
if (rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO)
return(PrintError(SQL_HANDLE_ENV, henv));
/* commit work*/
rc = SQLEndTran(SQL_HANDLE_DBC, hdbc, SQL_COMMIT);
if (rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO)
return(PrintError(SQL_HANDLE_DBC, hdbc));
rc = SQLExecDirectW(hstmt,create,SQL_NTS);
if (rc == SQL_ERROR)
return(PrintError(SQL_HANDLE_STMT,hstmt));
/* commit work*/
rc = SQLEndTran(SQL_HANDLE_DBC, hdbc, SQL_COMMIT);
if (rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO)
return(PrintError(SQL_HANDLE_DBC, hdbc));
id = 100;
strcpy(name, "SOLID");
rc = SQLExecute(hstmt);
if (rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO)
return(PrintError(SQL_HANDLE_DBC, hdbc));
/* commit work*/
rc = SQLEndTran(SQL_HANDLE_DBC, hdbc, SQL_COMMIT);
rc = SQLFreeStmt(hstmt, SQL_CLOSE);
if (rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO)
return(PrintError(SQL_HANDLE_STMT, hstmt));
rc = SQLFetch(hstmt);
if (rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO)
return(PrintError(SQL_HANDLE_DBC, hdbc));
rc = SQLFetch(hstmt);
assert(rc == SQL_NO_DATA);
rc = SQLFreeStmt(hstmt, SQL_CLOSE);
if (rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO)
return(PrintError(SQL_HANDLE_STMT,hstmt));
return(0);
}
/***************************************************************
Function Name: main
Purpose : To Control all operations
***************************************************************/
void main(SQLINTEGER argc, SQLCHAR *argv[])
{
puts("\n\t SOLID ODBC Driver 3.51:");
puts("\n\t -Usage of static SQL functions");
puts("\n\t ==============================");
if (argc != 4){
puts("USAGE: Example1 <DSN name> <username> <passwd>");
exit(0);
}
else {
example1(argv[1], argv[2], argv[3]);
}
}
The following example illustrates how an application can determine the nature of
the resultset prior to retrieving results.
/***************************************************************
Sample Name : Example2.c(ad-hoc query processing)
Author : IBM
***************************************************************/
#if (defined(SS_UNIX) || defined(SS_LINUX))
#include <solidodbc3.h>
#else
#include <windows.h>
#endif
#include <stdio.h>
#ifndef TRUE
#define TRUE 1
#endif
SQLHENV henv;
SQLHDBC hdbc;
SQLHSTMT hstmt;
/***************************************************************
rc = SQLGetDiagRec(handleType, handle, 1,
(SQLCHAR *)&sqlState, (SQLINTEGER *)&nError,
(SQLCHAR *)&eMsg, 255, NULL);
if (rc == SQL_SUCCESS || rc == SQL_SUCCESS_WITH_INFO) {
printf("\n\t Error:%s\n",eMsg);
}
return(SQL_ERROR);
}
/**************************************************************
Function Name: DrawLine
Purpose : To Draw a specified character (line) for
specified number of times (len)
**************************************************************/
void DrawLine(SQLINTEGER len, SQLCHAR line)
{
printf("\n");
while(len > 0) {
printf("%c",line);
len--;
}
printf("\n");
/***************************************************************
Function Name: example2
Purpose : Connect to the specified data source and
execute the given SQL statement.
***************************************************************/
SQLINTEGER example2(SQLCHAR *sqlstr)
{
SQLINTEGER i;
SQLCHAR colname[32];
SQLSMALLINT coltype;
SQLSMALLINT colnamelen;
SQLSMALLINT nullable;
SQLINTEGER collen[MAXCOLS];
SQLSMALLINT scale;
SQLINTEGER outlen[MAXCOLS];
SQLCHAR data[MAXCOLS][MAX_DATA_LEN];
SQLSMALLINT nresultcols;
SQLINTEGER rowcount, nRowCount=0, lineLength=0;
SQLRETURN rc;
printf("\n%s",sqlstr);
DrawLine(strlen(sqlstr),’=’);
rc = SQLNumResultCols(hstmt, &nresultcols);
if (rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO)
return(PrintError(SQL_HANDLE_STMT, hstmt));
if (nresultcols == 0) {
rc = SQLRowCount(hstmt, &rowcount);
if (rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
return(PrintError(SQL_HANDLE_STMT, hstmt));
}
if (rowcount > 0 ) {
printf("%ld rows affected.\n", rowcount);
}
else {
printf("Operation successful.\n");
}
}
/* Otherwise, display the column names of the result */
/* set and use the display_size() function to */
/* compute the length needed by each data type. */
/* Next, bind the columns and specify all data will */
/* be converted to char. Finally, fetch and print */
/* each row, printing truncation messages as */
/* necessary. */
else {
for (i = 0; i < nresultcols; i++) {
rc = SQLDescribeCol(hstmt, i + 1, colname,
(SQLSMALLINT)sizeof(colname),
&colnamelen, &coltype, &collen[i],
&scale, &nullable);
if (rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO){
return(PrintError(SQL_HANDLE_STMT, hstmt));
}
/* print column names */
printf("%s\t", colname);
rc = SQLBindCol(hstmt, i + 1, SQL_C_CHAR,
data[i], sizeof(data[i]), &outlen[i]);
if (rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO){
return(PrintError(SQL_HANDLE_STMT, hstmt));
}
lineLength += 6 + strlen(colname);
}
DrawLine(lineLength-6,’-’);
while (TRUE) {
rc = SQLFetch(hstmt);
if (rc == SQL_SUCCESS || rc == SQL_SUCCESS_WITH_INFO){
nRowCount++;
for (i = 0; i < nresultcols; i++) {
if (outlen[i] == SQL_NULL_DATA) {
else {
if (rc == SQL_ERROR)
PrintError(SQL_HANDLE_STMT, hstmt);
break;
}
}
printf("\n\tTotal Rows:%d\n", nRowCount);
}
SQLFreeStmt(hstmt, SQL_UNBIND);
SQLFreeStmt(hstmt, SQL_CLOSE);
return(0);
/***************************************************************
Function Name: main
Purpose : To Control all operations
***************************************************************/
int __cdecl main(SQLINTEGER argc, SQLCHAR *argv[])
{
SQLRETURN rc;
if (argc != 4) {
puts("USAGE: Example2 <DSN name> <username> <passwd>");
exit(0);
}
rc = SQLSetEnvAttr(henv, SQL_ATTR_ODBC_VERSION,
(SQLPOINTER)SQL_OV_ODBC3, SQL_NTS);
if (rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO)
return(PrintError(SQL_HANDLE_ENV, henv));
return(0);
For additional information about the ODBC SDK tools, see the Microsoft ODBC
SDK Guide.
The JDBC API defines Java classes to represent database connections, SQL
statements, result sets, database metadata, and so on. It allows a Java programmer
to issue SQL statements and process the results. JDBC is the primary API for
database access in Java. More information on the JDBC technology can be found at
the JDBC Technology Homepage ([Link]
The solidDB JDBC Driver is written entirely in Java and it communicates directly
with the solidDB server using the TCP/IP network protocol. The solidDB JDBC
Driver does not require any additional database access libraries. The driver
requires that a Java Runtime Environment (JRE) or Java Development Kit (JDK) is
available.
The JDBC API defines Java classes to represent database connections, SQL
statements, result sets, database metadata, and so on. It allows a Java programmer
to issue SQL statements and process the results. JDBC is the primary API for
database access in Java. More information about the JDBC technology can be found
at the JDBC Technology Homepage ([Link]
solidDB's JDBC driver is written entirely in Java and communicates directly with
the solidDB server using the TCP/IP network protocol. The solidDB driver does
not require any additional database access libraries, such as ODBC. The driver
requires that a JRE (Java Runtime Environment) or JDK (Java Development Kit) is
available.
The solidDB JDBC Driver is a solidDB implementation of the JDBC 2.0 standard. It
is usable in all Java environments supporting JDK 1.4.2 and above.
The solidDB JDBC Driver is installed during the solidDB server installation into
the jdbc directory.
If your application is located on a different computer than the solidDB server, you
need to copy the JDBC driver file to the computer where the application is located.
Tip:
51
v The jdbc directory contains also the solidDB Data Store Helper Class
([Link]) for use with WebSphere®.
v The samples/jdbc directory in the solidDB installation directory contains Java
code samples that use the solidDB JDBC Driver. Instructions for running the
sample are available in the [Link] file, which located in the same directory.
The CLASSPATH environment variable for your environment needs to include the
solidDB JDBC Driver .jar file installation path.
v Windows
The installation adds the default solidDB JDBC Driver installation path to the
System CLASSPATH environment variable automatically.
You can check and set the System CLASSPATH environment variable through
the Control Panel:
Control Panel > System > Advanced > Environment Variables
v Linux and UNIX
Set your CLASSPATH environment variable to include the solidDB JDBC Driver
([Link]) installation path.
For example, in Bourne shell, use the following command:
export CLASSPATH=<solidDB installation directory>/jdbc/[Link]:$CLASSPATH
If you are using another shell than the Bourne shell, modify this command to
make it appropriate for your shell.
The driver can be registered as shown below. After execution of this code, the
driver registers itself in the DriverManager.
// registration using [Link] service
[Link]("[Link]");
The syntax of the JDBC URL (connection string) for solidDB is:
jdbc:solid://<hostname>:<port>/<username>/<password>[?<property-name>=<value>]...
For example, the following connect string attempts to connect to a solidDB server
in machine fb9 listening to the tcp/ip protocol at port 1314:
"jdbc:solid://fb9:1314/dba/dba"
Database errors in JDBC are handled and managed by the exception mechanism.
Most of the methods specified in JDBC interfaces may throw an instance of
SQLException. As these errors may appear in the normal application workflow
(representing concurrency conflicts, for instance) your code should be tolerant to
such errors. Basically, you must not leave your connections in any other state than
"closed" regardless of the result of your code's execution. This approach allows
avoiding situations where all available connections remain open due to unhandled
exceptions.
You can get an exception's error code by calling [Link](). For listings of
solidDB error codes, see the Appendix Error codes in IBM solidDB Administrator
Guide.
The following code example shows a correct way of handling errors coming from
the database:
Public void listTablesExample() {
try {
[Link]("[Link]");
} catch (ClassNotFoundException e) {
[Link]("Solid JDBC driver is not registered
in the classpath");
return; //exit from the method
}
Connection conn = null;
Statement stmt = null;
ResultSet rs = null;
try {
conn = [Link]("jdbc:solid://
localhost:1313", "dba", "dba");
stmt = [Link]();
rs = [Link]("SELECT * FROM tables");
while ([Link]()) {
[Link]([Link](0));//printing
out results
}
} catch (SQLException e) {
[Link]();
} finally {
/* It’s a good idea to release
resources in a finally{} block
in reverse-order of their creation
if they are no-longer needed
*/
if (rs != null) {
try {
[Link]();
} catch (SQLException sqlEx) { // ignore
rs = null;
}
}
if (stmt != null) {
try {
[Link]();
} catch (SQLException sqlEx) { // ignore
stmt = null;
}
}
}
if (conn != null)
try {
[Link]();
In some functions, the JDBC specification leaves some details open. For the details
particular to solidDB's implementation of the methods, check “JDBC driver
interfaces and methods”.
The solidDB JDBC Driver provides support for catalogs and schemas in solidDB.
Note: solidDB stored procedures can return result sets. Calling procedures through
the JDBC CallableStatement interface is not necessary. For an example of calling
solidDB procedures using JDBC, see the source code for the Sample 3 application
in “Code examples” on page 78.
This topic describes solidDB-specific differences from the standard API. You can
browse standard packages and interfaces in the [Link] and [Link] packages,
and see details of a particular implementation by checking the list of "All Known
Implementing Classes".
For a description of how different data types are supported by solidDB JDBC
Driver, see “solidDB JDBC Driver type conversion matrix” on page 90.
Array
The [Link] interface is not supported. This interface is used to map SQL
type Array in the Java programming language. It reflects the SQL-99 standard that
is currently unavailable in solidDB.
Blob
The [Link] interface is not supported. This interface is used to map SQL type
Blob in the Java programming language. It reflects the SQL-99 standard that is
currently unavailable in solidDB.
Note: The JDBC Driver allows for the creation of a Statement object that generates
ResultSet objects with the given type and concurrency. This differs from the
createStatement method in JDBC 1.0 because it allows the default result set type
and result set concurrency type to be overridden.
Following are the differences from the standard CallableStatement interface defined
in the JDBC API.
Table 15. Differences to the Standard CallableStatement Interface
Clob
The [Link] interface is not supported. This interface is used to map SQL type
Clob in the Java programming language. It reflects the SQL-99 standard that is
currently unavailable in solidDB.
Connection
Following are the differences from the standard Connection interface defined in the
JDBC API.
Table 16. Differences to the Standard Connection Interface
DatabaseMetaData
For a description of how different data types are supported by solidDB JDBC
Driver, see “solidDB JDBC Driver type conversion matrix” on page 90.
Driver
PreparedStatement
Subinterfaces: CallableStatement
Ref
This interface is a reference to an SQL structured type value in the database. This
interface is not supported by solidDB.
ResultSet
SQLData
SQLInput
The [Link] interface is not supported. This interface is an input stream
that represents an instance of an SQL structured or distinct type. It reflects the
SQL-99 standard that is currently unavailable in solidDB.
SQLOutput
Statement
Note: The JDBC Driver allows for the creation of a Statement object that generates
ResultSet objects with the given type and concurrency. This differs from the
CreateStatement method in JDBC 1.0 because it allows the default result set type
and result set concurrency type to be overridden.
Subinterfaces:
v CallableStatement
v PreparedStatement
Following are the differences from the standard Statement interface defined in the
JDBC API.
Table 19. Differences to the Standard Statement Interface
Struct
The [Link] interface is not supported. This interface represents the standard
mapping in the Java programming language for an SQL structured type. It reflects
the SQL-99 standard that is currently unavailable in solidDB.
ResultSet (updateable)
Following are the differences from the standard ResultSet interface defined in the
JDBC API.
Table 20. Differences to the Standard ResultSet Interface
When using JTA with SQL passthrough in solidDB Universal Cache, only read
statements (SELECT) are supported.
WebSphere needs an adapter class for those JDBC data sources that are to be used
within WebSphere. The base class for these adapters is the
[Link] class; solidDB implements
its own version of this adapter inside a class
called:[Link].
This class is provided within the solidDB product as a separate archive file called
[Link] You can find this file in the jdbc directory in the
solidDB installation directory.
When you are configuring a new solidDB data source in WebSphere, you need to
v give the [Link] in the data
store helper field of the configuration, and
v specify the full path to the [Link] file in the data source
configuration of WebSphere.
See the WebSphere documentation for further details how to define new data
sources in WebSphere.
You need to define the following properties when configuring a new data source in
the WebSphere:
URL
v type: [Link]
v value should use syntax similar to the following syntax: 'jdbc:solid://
<hostname>:<port>'
user
v type: [Link]
v value should be a valid user name
password
Connection timeout means response timeout of any JDBC call invoking data
transmission over a connection socket. If the response message is not received
within the time specified, an I/O exception is thrown. The JDBC standard (2.0/3.0)
does not support setting of the connection timeout. solidDB has introduced two
ways for doing that: one using a non-standard driver manager extension method
and the other one using the property mechanisms. The time unit in either case is
one millisecond.
The following example illustrates the solution. The effect of the setting is
immediate. This allows to set the timeout to zero if you want to force-disconnect.
//Import Solid JDBC:
import [Link].*;
The following example shows how to set the statement cache size using the use
the StatementCache property.
Timeout properties
solid_connection_timeout_ms – Connection timeout
Sets the connection timeout value in milliseconds. The property must be
set before getting a new connection. Once a connection object is created,
changing the property value has no effect.
solid_login_timeout_ms – Login timeout
Sets the timeout in milliseconds for opening of a connection.
The following example shows how to set a connect timeout using the
solid_connection_timeout_ms property.
// Set connection timeout with "solid_connection_timeout_ms" property //
public class Test {
//
// Put connection timeout in the property object
//
[Link]("solid_connection_timeout_ms", "10000");
try {
// create driver
Driver d = (Driver)(
[Link]("[Link]").newInstance());
} catch ( Exception e ) {
; // save the day
}
}
}
Appinfo property
solid_appinfo
Sets unique identifiers for applications running in the same computer and
under the same username for the purposes of tracing and management.
By default, the value (a string) is not set.
The value can be retrieved on the server side with the command ADMIN
COMMAND ’userlist’.
Transparent connectivity (TC) is a connection mode that can be used with solidDB
High Availability configurations. The following connection properties are available
with TC.
solid_tf_level – Failure transparency level
Sets the transparent failover level for the connection.
Three levels are available:
v NONE | 0 – failure transparency is disabled. This is the default value.
v CONNECTION | 1 – the server connection is preserved, that is, it is
unnecessary to reconnect in the case of failover or switchover.
v SESSION | 3 – certain session attributes that have non-default values are
preserved. Additionally, prepared statements are preserved. However,
open cursors are closed, and ongoing transactions are aborted.
Note: The value is a string; you can specify it as a mnemonic (for example,
NONE) or as a number (0 for NONE). For clarity, use of mnemonics is
preferable.
solid_preferred_access – Load balancing mode
Sets the preferred access mode for the connection to define whether
read-only loads are distributed.
The following levels are available:
v WRITE_MOSTLY | 0 – the workload is directed to Primary. This is the
default value. WRITE_MOSTLY also sets the connection to the WRITE MOSTLY
mode. It is not possible to do that by specifying a numeric value.
v READ_MOSTLY | 1 – the workload is directed by default to Secondary. The
write transactions are handed over to the Primary.
For more information about using the TC connection properties, see section Using
the Transparent Connectivity in the IBM solidDB High Availability User Guide.
For example:
Properties props = new Properties();
// enable the direct access property
[Link]("solid_shared_memory", "yes");
// get connection
Connection c = [Link]
("jdbc:solid://localhost:1315", props);
For more details, see Making JDBC connections for SMA in the IBM solidDB Shared
Memory Access and Linked Library Access User Guide.
The SQL passthrough mode can be set with the following connection properties:
solid_passthrough_read
Sets the SQL passthrough mode for read-type statements to NONE,
CONDITIONAL, or FORCE.
solid_passthrough_write
Sets the SQL passthrough mode for write-type statements to NONE,
CONDITIONAL, or FORCE.
For more information about the SQL passthrough and the passthrough modes, see
section Setting SQL passthrough mode in the IBM solidDB Universal Cache User Guide.
The catalog name and schema name can be set with the following connection
properties:
solid_catalog
Sets the solidDB catalog name.
solid_schema
Sets the solidDB schema name.
Any connection property can also be set at connect time within the JDBC URL
passed to the JDBC method [Link](). The syntax of solidDB
JDBC URL is the following:
"jdbc:solid://<hostname>:<port>/>username>/<password>[?<property-name>=<value>]..."
Examples
"jdbc:solid://locahost:1964/dba/dba"
"jdbc:solid://[Link]/dba/dba?solid_login_timeout_ms=100"
"jdbc:solid://[Link]/dba/dba?solid_login_timeout_ms=100?solid_idle_timeout_min=5"
Note: solidDB does not provide an implementation for the actual connection pool;
the data structure and the logic to actually pool the PooledConnection instances
are not available. You must implement your own connection pooling logic, that is,
a class that actually pools the connections.
Parameters None
Parameters None
Description This function sets the url string which points to an solidDB
server.
Parameters None
Parameters None
Parameters None
Description This function sets the url string which points to an solidDB
server.
Parameters None
Parameters None
Parameters None
Parameters None
throws [Link]
throws [Link]
Description This function sets the handle to a writer object that will be
used to print/log debug messages.
throws [Link]
[Link] listener)
Parameters None
throws [Link]
Parameters None
throws [Link]
Parameters listener
[Link] listener)
/**
* Create a SolidJDBCRowSet with an existing ResultSet handle */
public SolidJDBCRowSet([Link] rset)
/**
* Create a new SolidJDBCRowSet with given url, username and
* password.
*/
public SolidJDBCRowSet(String url, String uname, String pwd)
/**
* Create a new SolidJDBCRowSet with given url, username,
* password and JNDI naming context.
*/
public SolidJDBCRowSet(String dsname,
String username,
String password,
Context namingcontext)
For examples, see the method interface description in the Java 2 Platform, Standard
Edition, v 1.4.2 API Specification: [Link]
sql/[Link]
There are certain methods that you can call (usually for setting parameters for
commands to be executed or setting the properties of the RowSet instance) before a
connection to the database has been made. However, most of the RowSet interface
methods can be called only after a connection to the database has been made. This
means that method a command has been set with method setCommand(String)
and method execute() has been called. If the SolidJDBCRowSet instance has no
previous [Link] handle, the connection will be established during
execute() call. After the execute() call, the row set instance contains a
[Link] object, a [Link] object, and if the command
execute was a query statement, it contains also a [Link] handle. It also
contains all parameter setting methods: setString, setObject, and so on.
/**
* Note! You can set command parameters and other properties
* in any order you like, for example, you can set the parameters
* before you have defined the command to be executed. You can
* also define the command parameters in any order, since the
* command statement as well as the given parameters will not be
* parsed until a connection to the database has been made in
* the execute() method call.
*/
// close the result set. This method call closes the connection
// to the database as well.
[Link]()
Code examples
This topic contains four Java code samples that use the solidDB JDBC driver.
import [Link].*;
stmt= [Link]();
[Link]();
[Link]();
// and not it is all over
[Link]("\nResult set dumped. Sample application finishes.");
}
}
jdbc:solid://<host>:<port>/<user name>/<password>
import [Link].*;
import [Link].*;
import [Link];
import [Link];
import [Link].*;
url = getParameter("url");
[Link] = [Link];
[Link](textField, c);
add(textField);
[Link] = [Link];
[Link] = 1.0;
[Link] = 1.0;
[Link](textArea, c);
add(textArea);
validate();
try {
// Load the Solid JDBC Driver
Driver d =
(Driver)[Link] ("[Link]").newInstance();
//------------------------------------------------------------------
// checkForWarning
// Checks for and displays warnings. Returns true if a warning
// existed
//------------------------------------------------------------------
if (warn != null) {
[Link]("\n*** Warning ***\n");
rc = true;
while (warn != null) {
[Link]("SQLState: " +
[Link] () + "\n");
[Link]("Message: " +
[Link] () + "\n");
[Link]("Vendor: " +
[Link] () + "\n");
[Link]("\n");
warn = [Link] ();
//------------------------------------------------------------------
// dispResultSet
// Displays all columns and rows in the given result set
//------------------------------------------------------------------
import [Link].*;
import [Link].*;
DoIt();
[Link]();
// and now it is all over
[Link](
"\nResult set dumped. Sample application finishes."
);
}
ResultSet rs = [Link]();
if (rs != null) {
ResultSetMetaData md = [Link]();
int cols = [Link]();
int row = 0;
while ([Link]()) {
row++;
String ret = "row "+row+": ";
for (int i=1;i<=cols;i++) {
ret = ret + [Link](i) + " ";
}
[Link](ret);
}
}
[Link]();
}
catch (SQLException ex) {
printexp(ex);
}
catch ([Link] ex) {
[Link] ();
}
try {
stmt = [Link]();
[Link]("drop procedure sample3");
} catch (SQLException ex) {
printexp(ex);
}
try {
[Link](proc);
} catch (SQLException ex) {
printexp(ex);
[Link](-1);
}
}
import [Link].*;
if ([Link] < 1) {
[Link]("usage: java sample4 <infile>");
[Link](0);
}
filename = args[0];
tmpfilename = "[Link]";
[Link]("JDBC sample application starts...");
[Link]("Application tries to register the driver.");
[Link]();
// and it is all over
[Link]("\nSample application finishes.");
}
}
[Link]();
[Link]("Read "+readsize+" bytes from database");
}
catch (SQLException ex) {
printexp(ex);
}
catch ([Link] ex) {
[Link] ();
}
try {
stmt = [Link]();
[Link]("drop table sample4");
} catch (SQLException ex) {
printexp(ex);
}
try {
[Link](proc);
} catch (SQLException ex) {
printexp(ex);
[Link](-1);
}
getArray/setArray
getBlob/setBlob
getByte/setByte X X X X X X X X X X X X X X
getCharacterStream/ setCharacterStream X X X X X X X X X X X X
getClob/setClob
getShort/setShort X X X X X X X X X X X
getInt/setInt X X X X X X X X X X X
getlong/setLong X X X X X X X X X X X
getfloat/setfloat X X X X X X X X X X X
getDouble/setDouble X X X X X X X X X X X
getBigDecimal/setBigDecimal X X X X X X X X X X X
getRef/setRef
getBoolean/setBoolean X X X X X X X X X X X
getString/setString X X X X X X X X X X X X X X X X X X X X
getBytes/setBytes X X X X X X X X X
getDate/setDate X X X X X X X X
getTime/setTime X X X X X X X X
getTimestamp/setTimestamp X X X X X X X X
getAsciiStream/setAsciiStream X X X X X X X X X
getUnicodeStream/setUnicodeStream X X X X X X X X X
getBinaryStream/setBinaryStream X X X X X X X X X
getObject/setObject X X X X X X X X X X X X X X X X X X X X
The solidDB SA interface bypasses the SQL parser, interpreter, and optimizer. With
solidDB SA you can access result sets, as long as you are not using SQL through
solidDB SA. If retrieval of result sets is necessary through SQL, then you must use
industry standard APIs such as ODBC or the solidDB Light Client based on ODBC.
To use solidDB SA requires that you convert your existing interface. This is why
we recommend that you use solidDB SA only after you have already attempted
(with little success) to use other means for improving performance, which include:
v Writing or indexing columns by primary key for the most appropriate row order.
solidDB, otherwise, stores rows on disk in the order they are inserted into the
database.
v Eliminating unnecessary indexes. For example, a query that selects more than
15% of a table's rows may be performed faster by a full table scan.
v Optimizing the transaction size by committing transactions after every 100-200
rows inserted.
v Using stored procedures.
93
Getting started with solidDB SA
The solidDB SA can be used with shared memory access (SMA) and linked library
access (LLA). This topic describes the steps that you should take before using
solidDB SA.
Building an application program using the solidDB SA library in the linked library
access or the SA client library is identical to building any normal C/C++ program:
1. Insert the linked library access library file or SA client library into your project.
Refer to section Creating and running LLA applications in the IBM solidDB Shared
Memory Access and Linked Library Access User Guide for the correct filenames.
2. Include the following solidDB SA header file, which is required in applications
using solidDB SA library in the linked library access or the solidDB SA client
library:
#include "sa.h"
Insert the directory containing all the other necessary solidDB SA headers into
your development environment's include directories setting.
3. Compile the source code.
4. Link the program.
You can verify the development setup with the solidDB SA sample program. This
enables you to verify your development environment without writing any code.
For delete and update operations, after the cursor is created, a search is performed
so that the cursor points to the row that is to be updated and deleted. For insert
operations, after the cursor is created, the insertion row(s) are immediately written
to the cursor. solidDB SA also enables passing several rows for insertion inside a
single network message.
solidDB SA functions required for insert operations are listed in the table below.
After solidDB creates a cursor to a certain table, variables are bound to columns,
rows are written to the cursor, and then the cursor is closed.
Note: If you use SaArrayInsert to insert more than one row in a single message,
then you must perform an explicit flush to send the rows to the database.
Table 44. Insert operation steps
4. Write a row(s) to SaArrayInsert for more than one row or Perform this in a loop
the cursor SaCursorInsert for a single row if necessary
The following code sample excerpt demonstrates how to write four rows of data in
a single network message using the SaArrayInsert function. In the code, a call to
SaArrayFlush flushes all rows to the server so they are passed in the same network
message.
4 Using solidDB SA 95
scur = SaCursorCreate(scon, "SAEXAMPLE");
solidDB SA functions required for basic update and delete operations are listed in
the table below.
After solidDB creates a cursor to a specific table, variables are bound to columns of
the table, and the cursor is opened. Before the actual search begins, the constraints
for finding the row for deletion are set. If there are more rows to be updated, each
of the rows requires a separate fetch before they are updated or deleted. After the
operation, the cursor is freed.
Table 45. Update and delete operation steps
The following code sample excerpt demonstrates how to update a row in a table
using SaCursorUpdate. Note that in the code, the new values for the update are in
variables which are bound to the columns of the table using SaCursorColInt and
SaCursorColStr after the cursor is created.
scur = SaCursorCreate(scon, "SAEXAMPLE");
/* Start a search. */
SaCursorSearch(scur);
4 Using solidDB SA 97
With solidDB SA, data is queried using cursors. The query data is found in a way
similar to update and delete operations. A cursor is created to a specific table,
variables are bound to columns of the table, and the cursor is then opened. The
constraints for finding the rows for the query are set before starting the actual
search. If more than one row is found, each row must be fetched separately. After
all the rows are fetched, the cursor needs to be freed.
Basically, all solidDB SA queries use the solidDB optimizer in a way similar to
SQL-based queries. The index selection strategy is the same as in SQL. The only
exception is that the solidDB SA search uses ORDER BY for selecting an index.
This means that an index that best fits ORDER BY is the one selected. If two
indices are equally good, then the one with a smaller cost is selected. The query is
optimized each time SaCursorSearch is called.
Example
/* Create cursor to a database table. */
scur = SaCursorCreate(scon, "SAEXAMPLE");
/* Start a search. */
rc = SaCursorSearch(scur);
Example
/* Create test table and index. */
SaSQLExecDirect(scon,
"CREATE TABLE SAEXAMPLE(INTC INTEGER, CHARC VARCHAR)");
SaSQLExecDirect(scon,
"CREATE INDEX SAEXAMPLE_I1 ON SAEXAMPLE (CHARC)");
4 Using solidDB SA 99
details). To improve performance when inserting multiple rows with the
SaArrayInsert function, put multiple inserts into a single transaction by using
SaTransBegin and SaTransCommit.
The function SaCursorErrorInfo returns error text if the last cursor operation failed.
Note that SaErrorInfo has a connection parameter and thus returns the last error
applicable to that connection, while SaCursorErrorInfo has a cursor parameter and
thus returns the last error of that cursor.
Following are the possible return codes for solidDB SA functions. All of these error
codes are defined in the sa.h file.
Table 47. solidDB SA Function Return Codes
Note: SaArray* functions are not supported in linked library access; they work
only with the network client library. They return SA_ERR_CALLNOSUP with
linked library access.
Currently, solidDB SA does not support BLOB streams and the maximum size of
an attribute value is limited to 32K.
The SaCursorCol* functions support the SQL datatypes listed in the following
table.
Table 48. Supported SQL Datatype
L
O
L N
O V G
N L A V T
S G W O R A I
T M I D N V V V N B R M
I A N D E U A A A G B I B E
N L T F O C M R R W R W I N I S
Y L E R L U I E C C C C C V N A N D T T
SaCursolCol* I I G E O B M R H H H H H A A R A A I A
N N E A A L A I A A A A A R R Y R T M M
Function T T R L T E L C R R R R R C Y R Y E E P
SaCursorColInt X X X X X X X X X X X X X X
SaCursor ColLong X X X X X X X X X X X X X X
SaCursor ColFloat X X X X X X X X X X X X X X
SaCursor ColDouble X X X X X X X X X X X X X X
SaCursorColStr X X X
SaCursorCol Date X X X X X X X X
SaCursor ColTime X X X X X X X X
SaCursor ColTimestamp X X X X X X X X
SaCursor ColData X X X
SaCursor ColDynData X X X X X X X X X X X X X
SaCursor ColFixStr X X X X X X X X X X X X X X X X
SaCursor ColDynStr X X X X X X X X X X X X
Note: Keep in mind that, as in other APIs, the success of some conversions in
solidDB SA depend on declared values. For example, SaCursorCollInt is only able
to handle the SQL datatype CHAR (as in 'foo') if the actual value of the field is an
integer (as in '123').
Each description includes the purpose, synopsis, parameters, return value, and
comments.
Function Synopsis
The table below shows the possible usage type for solidDB SA parameters. Note
that if a parameter is used as a pointer, it contains a second category of usage to
specify the ownership of the parameter variable after the call.
Table 49. solidDB SA Parameter Usage Types
ref Applies only to out parameters. See "Return Value" below for
details.
give Applies only to out parameters. See "Return Value" below for
details.
Return value
Each function description indicates if the function returns a value and the type of
value that is returned. Return Values can be one of the following values:
v Boolean (TRUE, FALSE),
v int (such as 1, 0),
ref Indicates the caller can only reference the returned value, but
cannot release it. Ensure that the returned value is not used after
it is released by the object that returned it.
give Indicates the function gives the returned value to the caller. The
caller is responsible for releasing the returned value.
SaArrayFlush
SaArrayFlush flushes the array operation buffer (that is, it sends the data to the
server) after a series of calls to SaArrayInsert fills that buffer.
SaArray* functions are not supported in linked library access; they work only with
the network client library. They return SA_ERR_CALLNOSUP with linked library
access.
Synopsis
SaRetT SA_EXPORT_H SaArrayFlush(SaConnectT* scon, SaRetT* rctab)
Return Value
“SaArrayInsert.”
SaArrayInsert
SaArrayInsert inserts an array of values on one network message. This function
places the inserted value in the array insert buffer. You can flush the buffer (that is,
send the data to the server) using function SaArrayFlush.
SaArrayInsert may also perform an implicit flush if the internal cache becomes full.
However, to ensure that all rows are sent to the server, you should call
SaArrayFlush after you insert the last record using SaArrayInsert.
Note:
1. By default, all SA operations, even SaArrayInsert and SaArrayFlush operations,
are done in autocommit mode. See “SaArrayFlush” on page 105 for an
important note about performance.
2. SaArray* functions are not supported in linked library access; they work only
with the network client library. They return SA_ERR_CALLNOSUP with linked
library access.
Synopsis
SaRetT SA_EXPORT_H SaArrayInsert(SaCursorT* scur)
Return Value
See Also
SaColSearchCreate
SaColSearchCreate starts a column information search for a specified table.
Synopsis
SaColSearchT* SA_EXPORT_H SaColSearchCreate(
SaConnectT* scon,
char* tablename)
Return Value
Pointer to the column search object, or NULL if table does not exist.
SaColSearchFree
SaColSearchFree releases the column search object.
Synopsis
void SA_EXPORT_H SaColSearchFree(SaColSearchT* colsearch)
Return Value
None
SaColSearchNext
SaColSearchNext returns information about the next column in the table.
Synopsis
int SA_EXPORT_H SaColSearchNext(
SaColSearchT* colsearch,
char** p_colname,
SaDataTypeT* p_coltype)
p_colname out, ref Pointer to the local copy of the column name is stored
into * p_colname
p_coltype out Type of column is stored into * p_coltype. See the sa.h
file for a description of the SaDataTypeT data type and
the valid values that it can hold.
Value Description
SaConnect
SaConnect creates a connection to the solidDB server. Several connections can be
active at the same time, but operations in different connections are executed in
separate transactions.
Synopsis
SaConnectT* SA_EXPORT_H SaConnect(
char* servername,
char* username,
char* password)
Return Value
Table 58. SaConnect Return Value
SaCursorAscending
SaCursorAscending specifies ascending order criteria for a column.
To sort by more than one column, you must call this function once for each
column. If there is no key (primary key or index) on the column, then the rows are
sorted locally (on the client) rather than on the server side.
Return Value
SaCursorAtleast
SaCursorAtleast specifies the Atleast criterion for a column. Atleast criterion means
that the column value must be greater than or equal to the Atleast value. The
Atleast value is taken from the user variable currently bound to the column.
Synopsis
SaRetT SA_EXPORT_H SaCursorAtleast(
SaCursorT* scur,
char* colname)
Return Value
SaCursorAtmost
SaCursorAtmost specifies the Atmost criterion for a column. Atmost criterion
means that the column value must be less than or equal to the Atmost value. The
Atmost value is taken from the user variable currently bound to the column.
Synopsis
SaRetT SA_EXPORT_H SaCursorAtmost(
SaCursorT* scur,
char* colname)
Return Value
SaCursorBegin
SaCursorBegin positions the cursor to the beginning of the set. The subsequent call
to the SaCursorNext function returns the first row.
Synopsis
SaRetT SA_EXPORT_H SaCursorBegin(
SaCursorT* scur)
Return Value
SaCursorClearConstr
SaCursorClearConstr clears all search constraints from a cursor.
Synopsis
SaRetT SA_EXPORT_H SaCursorClearConstr(
SaCursorT* scur)
Return Value
A variable may be used multiple times after a single binding. For example, if you
wanted to insert multiple rows, you might create a loop in which you store
appropriate values in the bound variable and then invoke the INSERT operation.
The "bind" operation would only need to be done once before the loop; it would
not need to be executed inside the loop for each INSERT operation. Similarly, after
binding the variables once, you could retrieve many rows (one at a time) using the
SaCursorNext function. Each time that you retrieved a row, its values would be
copied into the bound variables. Note that the address of the data buffer does not
change; only the value stored there changes each time what you call SaCursorNext.
If the column has been set as a search constraint (rather like using a WHERE
clause in a SELECT statement), then the value for this constraint is set to the value
pointed to by the user data variable whose address is passed as dataptr. For
example, if the function SaCursorEquals has been called for the column, then the
server retrieves only the rows whose value exactly matches the current value of the
bound variable. Note that the search constraints are set up for the search
operations (SaCursorSearch, followed by calls to SaCursorNext) but may actually
be used to set the cursor to the correct position for other operations (such as
SaCursorUpdate or SaCursorDelete).Typically, updates are combined with searches
to update only some of the rows. This means that the values for columns which
have search constraints are used to define the affected rows (in effect the "WHERE"
clause in SQL) and other bound variables are used to define the new values for the
rest of the columns. Note that the same bound variable can be used in both the
search constraint and in the update/insert operation (just as the same column may
be used in both the WHERE clause and the "UPDATE ... SET col = value" clause of
an SQL UPDATE statement). If the same bound variable is used in both the search
constraint and to convey data back and forth between the client and the server, the
search constraint does not change each time that the data in the bound variable is
updated; the server uses the value that was in the bound variable at the time that
the search constraint was created (for example, when functions like
SaCursortAtmost() were called).
In search operations, the user variable is updated to contain the value of the
current row. Also, if search criteria are involved, this function is used to pass the
values for them. In insert and update operations the new value for the column is
taken from the user variable.
When the bound variable is used as an "in" parameter (for example, in INSERT or
UPDATE operations), the user is responsible for the allocation and freeing of the
buffer. When a bound variable is used as an "out" parameter, the SA layer allocates
and frees the buffers. When the variable is used as an "out" parameter, the value
stored to the user variable is a pointer to a buffer that contains a local copy of the
Synopsis
SaRetT SA_EXPORT_H SaCursorColData(
SaCursorT* scur,
char* colname,
char** dataptr,
unsigned* lenptr)
Return Value
SaCursorColDate
SaCursorColDate binds a user variable of type SaDateT to a database column.
In search operations, the user variable is updated to contain the value of the
current row. Also, if search criteria are involved, this function is used to pass the
values for them. In insert and update operations the new value for the column is
taken from the user variable.
Synopsis
SaRetT SA_EXPORT_H SaCursorColDate(
SaCursorT* scur,
char* colname,
SaDateT* dateptr)
See Also
SaCursorColDateFormat
SaCursorColDateFormat binds date format string to a database column.
In search operations, the user variable is updated to contain the value of the
current row. Also, if search criteria are involved, this function is used to pass the
values for them. Depending on the column data type, the format string should be
date, time, or timestamp format.
Synopsis
SaRetT SA_EXPORT_H SaCursorColDateFormat(
SaCursorT* scur,
char* colname,
char* dtformat)
Return Value
See Also
SaCursorColDfloat
SaCursorColDfloat binds a user variable of type SaDfloatT to a database column.
In search operations, the user variable is updated to contain the value of the
current row. Also, if search criteria are involved, this function is used to pass the
values for them. In insert and update operations, the new value for the column is
taken from the user variable.
Note: SaDFloatT corresponds to the SQL data type DECIMAL (not FLOAT).
4 Using solidDB SA 113
Synopsis
SaRetT SA_EXPORT_H SaCursorColDfloat(
SaCursorT* scur,
char* colname,
SaDfloatT* dfloatptr)
Return Value
See Also
“SaCursorColDouble.”
SaCursorColDouble
SaCursorColDouble binds a user variable of type double to a database column.
In search operations, the user variable is updated to contain the value of the
current row. Also, if search criteria are involved, this function is used to pass the
values for them. In insert and update operations the new value for the column is
taken from the user variable.
Note: The C-language data type "double" is equivalent to SQL data type "FLOAT".
Synopsis
SaRetT SA_EXPORT_H SaCursorColDouble(
SaCursorT* scur,
char* colname,
double* doubleptr)
Return Value
See Also
SaCursorColDynData
SaCursorColDynData binds a user variable of type SaDynDataT to a database
column.
In search operations, the user variable is updated to contain the value of the
current row. Also, if search criteria are involved, this function is used to pass the
values for them. In insert and update operations, the new value for the column is
taken from the user variable.
In search operations, the column data is stored to the SaDynDataT variable using
function SaDynDataMove, which overwrites the old data. The user is responsible
for releasing the SaDynDataT variable after the search ends using function
SaDynDataFree.
Dynamic data objects (SaDynDataT) are an abstraction that simplifies the handling
of variable length data. Although dynamic data can be used with all types of data,
it is best fit for variable length data (VARBINARY, LONG VARBINARY,
VARCHAR, LONG VARCHAR, and so on).
The memory management of the data object is hidden inside the object. Dynamic
data objects have two externally-visible attributes: the data and the length.
Typically, the functions SaDynDataMove and SaDynDataAppend are used to set
and modify the data value inside the dynamic data object. More memory will be
automatically allocated when necessary and all the associated memory will be
automatically deallocated when the dynamic data object is disposed of using
SaDynDataFree. The user can access the data or the length using the respective
functions SaDynDataGetData and SaDynDataGetLen.
The use of SaDynDataMove and SaDynDataAppend may not be feasible when the
data already exists completely in a memory buffer. In addition to increasing the
memory usage by keeping two copies of the same data, the overhead of the
memory copy may be significant if the buffers are large. Therefore, it may be wise
to directly assign the data pointer by using SaDynDataMoveRef (rather than
Synopsis
SaRetT SA_EXPORT_H SaCursorColDynData(
SaCursorT* scur,
char* colname,
SaDynDataT* dd)
Return Value
SaCursorColDynStr
SaCursorColDynStr binds a user variable of type SaDynStrT to a database column.
In search operations, the user variable is updated to contain the value of the
current row. Also, if search criteria are involved, this function is used to pass the
values for them. In insert and update operations, the new value for the column is
taken from the user variable.
In search operations, the column data is stored to the SaDynStrT variable using
function SaDynStrMove, which overwrites the old data. The user is responsible for
releasing the SaDynStrT variable after the search ends using function
SaDynStrFree.
The user may bind an SaDynStrT variable to any type of column (not just character
columns) and the data will be converted back and forth between the column type
and the Dynamic String type.
Dynamic String objects (SaDynStrT) are an abstraction that simplifies the handling
of variable length strings. Typically, the functions SaDynStrMove and
SaDynStrAppend are used to set and modify the data value inside the dynamic
string object. More memory will be automatically allocated when necessary and all
the associated memory will be automatically deallocated when the dynamic data
object is disposed of using SaDynStrFree.
Synopsis
SaRetT SA_EXPORT_H SaCursorColDynStr(
SaCursorT* scur,
char* colname,
SaDynStrT* ds)
Return Value
See Also
See “SaCursorColDynData” on page 115 for a more detailed discussion of binding
variables.
SaCursorColFloat
SaCursorColFloat binds a user variable of type float to a database column.
After the variable has been bound, it can be used to hold a value that will be
written to or read from a column, or that will be used to constrain a search
operation (for example, as part of the equivalent of a WHERE clause in SQL). In
search operations, the user variable is updated to contain the value read from the
current row that has been retrieved. Also, if search criteria are involved, this
function can be used to pass the values for them. In update and insert operations,
the new value is taken from the bound user variable and then written to the
column in the database.
Note: The C-language "float" data type corresponds to the SQL "SMALLFLOAT"
data type, not the SQL "FLOAT" data type.
Synopsis
SaRetT SA_EXPORT_H SaCursorColFloat(
SaCursorT* scur,
char* colname,
float* floatptr)
See Also
SaCursorColInt
SaCursorColInt binds a user variable of type int to a database column.
After the variable has been bound, it can be used to hold a value that will be
written to or read from a column, or that will be used to constrain a search
operation (for example, as part of the equivalent of a WHERE clause in SQL). In
search operations, the user variable is updated to contain the value read from the
current row that has been retrieved. Also, if search criteria are involved, this
function can be used to pass the values for them. In update and insert operations,
the new value is taken from the bound user variable and then written to the
column in the database.
Note: The C-language "int" data type is platform-dependent, while the SQL data
types (TINYINT, SMALLINT, INT, and BIGINT) are platform-independent. You
must be careful to map the appropriate C-language data type and value to the
corresponding SQL data type.
Synopsis
SaRetT SA_EXPORT_H SaCursorColInt(
SaCursorT* scur,
char* colname,
int* intptr)
Return Value
SaCursorColLong
SaCursorColLong binds a user variable to a database column.
After the variable has been bound, it can be used to hold a value that will be
written to or read from a column, or that will be used to constrain a search
operation (for example, as part of the equivalent of a WHERE clause in SQL). In
search operations, the user variable is updated to contain the value read from the
current row that has been retrieved. Also, if search criteria are involved, this
function can be used to pass the values for them. In update and insert operations,
the new value is taken from the bound user variable and then written to the
column in the database.
Note: The C-language "long" data type is platform-dependent, while the SQL data
types (TINYINT, SMALLINT, INT, and BIGINT) are platform-independent. You
must be careful to map the appropriate C-language data type and value to the
corresponding SQL data type.
Synopsis
SaRetT SA_EXPORT_H SaCursorColLong(
SaCursorT* scur,
char* colname,
long* longptr)
Return Value
See Also
SaCursorColNullFlag
SaCursorColNullFlag binds a NULL value flag to a column.
If the column value is NULL, then * p_isnullflag has a value 1,otherwise the value
is 0. The * p_isnullflag value is updated automatically during fetch operations. In
Synopsis
SaRetT SA_EXPORT_H SaCursorColNullFlag(
SaCursorT* scur,
char* colname,
int* p_isnullflag)
p_isnullflag in, hold Pointer to an integer variable into where the NULL status
is stored during fetch operations, and from where the
NULL status is taken during insert and update operations.
Return Value
See Also
SaCursorColStr
SaCursorColStr binds a user variable to a database column.
In search operations, the user variable is updated to contain the value of the
current row. Also, if search criteria are involved, this function is used to pass the
values for them. In insert and update operations the new value for the column is
taken from the user variable.
In search operations, the value stored to the user variable is a pointer to a local
copy of the column data. The data pointer is valid until the next SaCursorOpen or
SaCursorFree call, after which the pointer should not be referenced.
Synopsis
SaRetT SA_EXPORT_H SaCursorColStr(
SaCursorT* scur,
char* colname,
char** strptr)
Return Value
See Also
SaCursorColTime
SaCursorColTime binds a user variable of type SaDateT to a database column.
In search operations, the user variable is updated to contain the value of the
current row. Also, if search criteria are involved, this function is used to pass the
values for them. In insert and update operations, the new value for the column is
taken from the user variable.
Synopsis
SaRetT SA_EXPORT_H SaCursorColTime(
SaCursorT* scur,
char* colname,
SaDateT* timeptr)
Note: The data type of timeptr is indeed SaDateT; there is no separate SaTimeT for
time data.
Return Value
SaCursorColTimestamp
SaCursorColTimestamp binds a user variable of type SaDateT to a database
column.
In search operations, the user variable is updated to contain the value of the
current row. Also, if search criteria are involved, this function is used to pass the
values for them. In insert and update operations the new value for the column is
taken from the user variable.
Synopsis
SaRetT SA_EXPORT_H SaCursorColTimestamp(
SaCursorT* scur,
char* colname,
SaDateT* timestampptr)
Return Value
See Also
SaCursorCreate
SaCursorCreate creates a cursor to a table specified by table name. The operation
fails if the table does not exist.
Synopsis
SaCursorT* SA_EXPORT_H SaCursorCreate(
SaConnectT* scon,
char* tablename)
Return Value
The parameter scon has the Usage Type "hold" because the created cursor object
keeps referencing the scon object even after the function call has returned.
Table 79. Return Value
SaCursorDelete
SaCursorDelete deletes the current row in a cursor from the database. The cursor
must be positioned to a row.
Synopsis
SaRetT SA_EXPORT_H SaCursorDelete(SaCursorT* scur)
Return value
SaCursorDescending
SaCursorDescending specifies descending sorting criterion for a column.
To sort by more than one column, you must call this function once for each
column.
If there is no key (primary key, or index) on the column, then the rows are sorted
locally (on the client) rather than on the server side.
Synopsis
SaRetT SA_EXPORT_H SaCursorDescending(
SaCursorT* scur,
char* colname)
Return value
SaCursorEnd
SaCursorEnd positions the cursor to the end of the set. A subsequent call to
SaCursorPrev will position the cursor to the last row in the set.
Synopsis
SaRetT SA_EXPORT_H SaCursorEnd(
SaCursorT* scur)
Return value
SaCursorEqual
SaCursorEqual specifies an equal search criterion for a column.
Synopsis
SaRetT SA_EXPORT_H SaCursorEqual(
SaCursorT* scur,
char* colname)
SaCursorErrorInfo
SaCursorErrorInfo returns error information from the last operation in the cursor.
Synopsis
bool SA_EXPORT_H SaCursorErrorInfo(
SaCursorT* scur,
char** errstr,
int* errcode)
Return value
FALSE If there are no errors, errstr and errcode are not updated.
SaCursorFree
SaCursorFree releases a cursor. After this call the cursor pointer is invalid.
Synopsis
void SA_EXPORT_H SaCursorFree(SaCursorT* scur)
Return value
None.
Synopsis
SaRetT SA_EXPORT_H SaCursorInsert(SaCursorT* scur)
Return value
SaCursorLike
SaCursorLike specifies a like criterion for a column.
The value cannot contain any wild card characters like '_' or '%' in SQL. If such
characters exist in the column value, they are quoted with escape characters by the
system. Thus, the like value is effectively the same as the SQL like with no wild
card characters ending with a '%' character. For example, if you specify that the
engine should search for "MARK" in the column, then the engine will find all
values that start with "MARK", such as "MARK", "MARK SMITH", and
"MARKETING".
The like value is taken from the user variable bound to the column.
Synopsis
SaRetT SA_EXPORT_H SaCursorLike(
SaCursorT* scur,
char* colname,
int likelen)
SaCursorNext
SaCursorNext fetches the next row from the database. All user variables bound to
columns are updated.
Synopsis
SaRetT SA_EXPORT_H SaCursorNext(SaCursorT* scur)
Return value
SaCursorOpen
SaCursorOpen opens a cursor.
All SaCursorColXXX operations must be done before the cursor is opened. When
the cursor is opened, possible existing search is terminated. Also, all search criteria
specified for the cursor are cleared.
After the cursor is opened, user can insert new rows to the cursor or specify search
criteria. Cursor must be opened before a search can be started.
Synopsis
SaRetT SA_EXPORT_H SaCursorOpen(SaCursorT* scur)
Return value
SaCursorOrderbyVector
SaCursorOrderbyVector is used to specify the order of columns used in a search.
The initial value is taken from the user variable bound to the column.
Synopsis
SaRetT SA_EXPORT_H SaCursorOrderbyVector(
SaCursorT* scur,
char* colname)
Return Value
SA_RC_SUCC or error code.
SaCursorOrderbyVector example
/* These variables will be bound to the columns named "I" and "J" */
int i, j;
/* Bind variables to columns in this cursor. */
SaCursorColStr(scur, "I", ’i);
SaCursorColStr(scur, "J", ’j);
/* Set the values that we want to use in the search. */
i = 2;
j = 1;
/* Specify the order of the columns. */
SaCursorOrderByVector(scur, "I");
SaCursorOrderByVector(scur, "J");
/* Search the cursor for matching values. */
SaCursorSearch(scur);
The preceding would be the equivalent of the following SQL WHERE clause:
...WHERE (i,j) >= (2,1)
SaCursorPrev
SaCursorPrev fetches the previous row from the database. All user variables
currently bound to columns are updated.
Synopsis
SaRetT SA_EXPORT_H SaCursorPrev(SaCursorT* scur)
Return value
SA_RC_END Beginning of search (we are already at the first row, so there is no
previous row).
Note: SA_RC_END can apply to either end (start or finish) of the cursor.
SaCursorReSearch
SaCursorReSearch starts a new search using old search criteria.
Synopsis
SaRetT SA_EXPORT_H SaCursorReSearch(SaCursorT* scur)
The SaCursorReSearch function accepts the following
parameters:
Table 92. SaCursorReSearch Parameters
Return value
SaCursorSearch
SaCursorSearch starts a search in a cursor. After the search is started, the user can
fetch rows from the database. Every search is executed as a separate transaction
and it does not see any changes made by the current user or any other user after
the search is started.
Synopsis
SaRetT SA_EXPORT_H SaCursorSearch(SaCursorT* scur)
SaCursorSearchByRowid
SaCursorSearchByRowid starts a new search where the row specified by rowid
belongs to the search set.
To get the rowid for a particular record, read the value of the rowid column. Every
table has a rowid column; you do not need to explicitly create a rowid column
within a CREATE TABLE or ALTER TABLE statement.
Synopsis
SaRetT SA_EXPORT_H SaCursorSearchByRowid(
SaCursorT* scur,
void* rowid,
int rowidlen)
rowid in, use Pointer to a data area containing rowid. The rowid should
be in the form of a string (char *) despite the fact that it is
declared as "void *".
Return Value
SaCursorSearchReset
SaCursorSearchReset resets a search cursor.
The old search constraints are used, but their values are read again from the user
buffers (i.e. the parameters). This allows you to increase performance in situations
where you want to repeat a search using a query that is identical except for the
specific values used.
As an example, suppose that your existing code looks similar to the following:
You can improve performance in most cases by changing your code to look like
the following example:
...
/* Bind variable(s) to column(s). */
SaCursorColInt(scur, "MY_COL_NAME", &search_parameter1);
SaCursorSearchReset resets the cursor to the beginning of the new result set. For
example, if you reset a search with no constraints at all, it will reposition the
cursor to the beginning of the table.
Note: Ensure that you update the values of the search parameters in the buffers
before you call this function; the new values are read during this function call.
Limitations
1. SaCursorSearchReset() can not be used in the following scenarios:
Synopsis
SaRetT SA_EXPORT_H SaCursorSearchReset(
SaCursorT* scur
Return Value
SaCursorSetLockMode
SaCursorSetLockMode sets the cursor search mode.
Synopsis
SaRetT SA_EXPORT_H SaCursorSetLockMode(
SaCursorT* scur,
sa_lockmode_t lockmode)
Note: This function applies to any table; the table does not need to have a
particular lock mode for this function to apply.
Return Value
SA_RC_SUCC
SA_ERR_ILLENUMVAL
SaCursorSetPosition
SaCursorSetPosition positions the cursor to a row specified by a key value. The
key value is taken from user bound column variables which have a constraint
specification.
Synopsis
SaRetT SA_EXPORT_H SaCursorSetPosition(
SaCursorT* scur)
SaCursorSetRowsPerMessage
SaCursorSetRowsPerMessage sets the number of rows to be sent in one network
message from the server to the client.
The setting has no effect after the search has been started by function
SaCursorSearch.
Synopsis
SaRetT SA_EXPORT_H
SaCursorSetRowsPerMessage(
SaCursorT* scur,
int rows_per_message)
Return value
SA_RC_SUCC Success
SaCursorUpdate
SaCursorUpdate updates the current row in a cursor in the database.
The cursor must be positioned to a row. Column values for the new row are taken
from the user variables bound to columns.
Synopsis
SaRetT SA_EXPORT_H SaCursorUpdate(SaCursorT* scur)
SaDateCreate
SaDateCreate creates a new date object.
Synopsis
SaDateT* SA_EXPORT_H SaDateCreate(void)
Return value
Table 100. SaDateCreate Return Values
SaDateFree
SaDateFree releases a date object.
After this call, the date object is invalid and cannot be used.
Synopsis
void SA_EXPORT_H SaDateFree(SaDateT* date)
Return value
None.
SaDateSetAsciiz
SaDateSetAsciiz sets ASCII zero string date to a date object.
All fields are optional. The fields are scanned from the format string, and when a
match is found, the field is replaced with the proper value. All other characters in
the format are treated literally.
Double letters (for example, "MM", "DD", and so on) indicate that the values
should be expressed with two digits (values 1-9 will be preceded with the 0
character, for example, 01). Single letters indicate that the value should be
expressed with one digit if possible. For example, if you define the date format as
"YY-M-D" then the date January 2, 1999 will look like "99-1-2". If you define the
date format as "YY-MM-DD", then the date will look like "99-01-02"
The default date format is YYYY-MM-DD HH:NN:SS, where time fields are
optional.
Synopsis
SaRetT SA_EXPORT_H SaDateSetAsciiz(
SaDateT* date,
char* format,
char* asciiz)
Return Value
SA_RC_SUCC
SA_ERR_FAILED
SaDateSetTimet
SaDateSetTimet copies the input value from the variable named "timet" to the
variable named "date". The value is automatically converted from the format
time_t (the format returned by C-library function time()) to the format SaDateT.
Return value
SA_RC_SUCC
SA_ERR_FAILED
SaDateToAsciiz
SaDateToAsciiz stores the date in an ASCII zero-terminated string format.
Synopsis
SaRetT SA_EXPORT_H SaDateToAsciiz(
SaDateT* date,
char* format,
char* asciiz)
Return Value
SA_RC_SUCC
SA_ERR_FAILED
Synopsis
SaRetT SA_EXPORT_H SaDateToTimet(
SaDateT* date,
long* p_timet)
Return value
SA_RC_SUCC
SA_ERR_FAILED
SaDefineChSet
SaDefineChSet defines the client character set.
Synopsis
SaRetT SA_EXPORT_H SaDefineChSet(
SaConnectT* scon,
SaChSetT chset)
Note: The usage type of scon includes "out" because the scon parameter is
modified by this function call.
Return value
Synopsis
int SA_EXPORT_H SaDfloatCmp(
SaDfloatT* p_dfl1,
SaDfloatT* p_dfl2)
Return value
< -1 if p_dfl1 < p_dfl2
= 0 if p_dfl1 = p_dfl2
> 1 if p_dfl1 > p_dfl2
This parallels the strcmp() function in C, which returns a negative number if the
first parameter is less than the second, zero if the two are equal, and a positive
number (greater than zero) if the first parameter is greater than the second.
SaDfloatDiff
SaDfloatDiff calculates the difference of two dfloat values (that is, p_dfl1 - p_dfl2).
The result is stored into * p_result_dfl.
Synopsis
SaRetT SA_EXPORT_H SaDfloatDiff(
SaDfloatT* p_result_dfl,
SaDfloatT* p_dfl1,
SaDfloatT* p_dfl2)
SA_RC_SUCC
SA_ERR_FAILED
SaDfloatOverflow
SaDfloatOverflow checks if the dfloat contains an overflow value.
Synopsis
int SA_EXPORT_H SaDfloatOverflow(
SaDfloatT* p_dfl)
Return value
SaDfloatProd
SaDfloatProd calculates the product of two dfloat values. The result is stored into *
p_result_dfl.
Synopsis
SaRetT SA_EXPORT_H SaDfloatProd(
SaDfloatT* p_result_dfl,
SaDfloatT* p_dfl1,
SaDfloatT* p_dfl2)
SA_RC_SUCC
SA_ERR_FAILED
SaDfloatQuot
SaDfloatQuot calculates the quotient of two dfloat values (that is, p_dfl1 / p_dfl2 ).
The result is stored into * p_result_dfl.
Synopsis
SaRetT SA_EXPORT_H SaDfloatQuot(
SaDfloatT* p_result_dfl,
SaDfloatT* p_dfl1,
SaDfloatT* p_dfl2)
Return value
SA_RC_SUCC
SA_ERR_FAILED
SaDfloatSetAsciiz
SaDfloatSetAsciiz sets the value of the dfloat from a zero-terminated ASCII string.
Synopsis
SaRetT SA_EXPORT_H SaDfloatSetAsciiz(
SaDfloatT* p_dfl,
char* asciiz)
SA_RC_SUCC
SA_ERR_FAILED
SaDfloatSum
SaDfloatSum calculates the sum of two dfloat values. The result is stored into *
p_result_dfl.
Synopsis
SaRetT SA_EXPORT_H SaDfloatSum(
SaDfloatT* p_result_dfl,
SaDfloatT* p_dfl1,
SaDfloatT* p_dfl2)
Return value
SaDfloatToAsciiz
SaDfloatToAsciiz stores the dfloat value as an asciiz (zero-terminated ASCII) string.
Synopsis
SaRetT SA_EXPORT_H SaDfloatToAsciiz(
SaDfloatT* p_dfl,
char* asciiz)
SA_RC_SUCC
SA_ERR_FAILED
SaDfloatUnderflow
SaDfloatUnderflow checks if the dfloat contains an underflow value.
Synopsis
int SA_EXPORT_H SaDfloatUnderflow(
SaDfloatT* p_dfl)
Return value
SaDisconnect
SaDisconnect disconnects the user from the solidDB server.
Synopsis
void SA_EXPORT_H SaDisconnect(SaConnectT* scon)
Return Value
None.
SaDynDataAppend
SaDynDataAppend appends data to the dynamic data object.
Return Value
None.
See also
SaDynDataChLen
SaDynDataChLen changes the data area length of dynamic data object. It allocates
and deallocates memory as necessary.
If the new length is smaller than the current length, the data area is truncated. If
the new length is greater than the current length, the new data area content is
initialized with space characters.
Synopsis
void SA_EXPORT_H SaDynDataChLen(
SaDynDataT* dd,
unsigned len)
None.
See Also
SaDynDataClear
SaDynDataClear deallocates the memory allocations from an SaDynDataT object.
SaDynDataClear deallocates the data; it does not deallocate the SaDynDataT object
itself. The result of SaDynDataClear leaves an "empty" dynamic data object
returned by SaDynDataCreate. The SaDynDataT object itself must be deallocated
separately using the SaDynDataFree function.
Synopsis
void SA_EXPORT_H SaDynDataClear(
SaDynDataT* dd)
Return Value
None.
See Also
SaDynDataCreate
SaDynDataCreate creates a new dynamic data object. A dynamic data object is an
object that can hold variable amounts of any type of data.
Synopsis
SaDynDataT* SA_EXPORT_H SaDynDataCreate(void)
See Also
SaDynDataFree
SaDynDataFree releases a dynamic data object. After this call, the dynamic data
object pointer is invalid and cannot be used.
Synopsis
void SA_EXPORT_H SaDynDataFree(
SaDynDataT* dd)
Return Value
None
See also
SaDynDataGetData
SaDynDataGetData returns the pointer to the data area of the dynamic data object.
Synopsis
char* SA_EXPORT_H SaDynDataGetData(
SaDynDataT* dd)
See also
SaDynDataGetLen
SaDynDataGetLen returns the length of the data area of the dynamic data object.
Synopsis
unsigned SA_EXPORT_H SaDynDataGetLen(
SaDynDataT* dd)
Return Value
Data area length. The function returns 0 if there is an error, or if the actual length
of the data area is 0.
See Also
SaDynDataMove
SaDynDataMove copies data from the parameter named "data" to a dynamic data
object (named dd). This function overwrites possible existing data.
The parameter dd must point to a Dynamic Data Object previously created with
the SaDynDataCreate function.
Note: SaDynDataMove copies the data. To copy just the reference rather than the
data, see “SaDynDataMoveRef” on page 148.
The use of SaDynDataMove and SaDynDataAppend may not be feasible when the
data already exists completely in a memory buffer. In addition to increasing the
memory usage by keeping two copies of the same data, the overhead of the
Synopsis
void SA_EXPORT_H SaDynDataMove(
SaDynDataT* dd,
char* data,
unsigned len)
Return Value
None.
See Also
“SaDynDataMoveRef.”
SaDynDataMoveRef
SaDynDataMoveRef moves a data reference to a dynamic dataobject.
SaDynDataMoveRef copies the pointer (address) from the parameter named "data"
to the appropriate field of the parameter named "dd". The caller must guarantee
that the input data is alive as long as the dynamic data object refers to that data.
Note: This function copies only the reference, not the data. To copy the data rather
than just the reference, see “SaDynDataMove” on page 147.
The use of SaDynDataMove and SaDynDataAppend may not be feasible when the
data already exists completely in a memory buffer. In addition to increasing the
Synopsis
void SA_EXPORT_H SaDynDataMoveRef(
SaDynDataT* dd,
char* data,
unsigned len)
Return Value
None
See Also
SaDynStrAppend
SaDynStrAppend appends another string at the end of a dynamic string.
Synopsis
void SA_EXPORT_H SaDynStrAppend(
SaDynStrT* p_ds,
char* str)
None.
SaDynStrCreate
SaDynStrCreate creates (initializes) a new dynamic string object.
Synopsis
SaDynStrT SA_EXPORT_H SaDynStrCreate(void)
Return Value
Table 127. SaDynStrCreate Return Value
SaDynStrFree
SaDynStrFree frees the SaDynStrT variable.
In search operations, the column data is stored to the SaDynStrT variable using
function SaDynStrMove, which overwrites the old data. The user is responsible for
releasing the SaDynStrT variable after the search ends using function
SaDynStrFree.
Synopsis
void SA_EXPORT_H SaDynStrFree(
SaDynStrT* p_ds)
Note: Because the function deallocates the memory, the pointer p_ds is no longer
valid after the function call and thus the usage type is "take".
Return Value
None.
SaDynStrMove
SaDynStrMove copies the value of the string (the second parameter) to the
SaDynStrT (the first parameter).
CAUTION:
Do not copy a SaDynStrT to another SaDynStrT (for example with memcpy).
This would result in two SaDynStrT pointers pointing at the same allocated
area.
Synopsis
void SA_EXPORT_H SaDynStrMove(
SaDynStrT* p_ds,
char* str)
Return Value
None.
SaErrorInfo
SaErrorInfo returns error information from the last operation in a server
connection.
Synopsis
bool SA_EXPORT_H SaErrorInfo(
SaConnectT* scon,
char** errstr,
int* errcode)
errstr out, ref If there was an error, and if this parameter is non-NULL,
then a pointer to a local copy of an error string is stored
into *errstr.
Return Value
FALSE There were no errors, so errstr and errcode were not updated.
SaGlobalInit
SaGlobalInit performs some global initialization in the SA system.
This function must be called before any other SA function except SaConnect. If the
SaConnect function is called before any other SA function, then you do not need to
call SaGlobalInit because SaConnect will call it for you.
Synopsis
void SA_EXPORT_H SaGlobalInit(void)
Return Value
None.
SaSetDateFormat
SaSetDateFormat defines default date format.
For explanation of the possible date formats, see “SaDateToAsciiz” on page 137.
Synopsis
SaRetT SA_EXPORT_H SaSetDateFormat(
SaConnectT* scon,
char* dateformat)
Note: The usage type includes "out" because the scon parameter is modified by
this function call.
SA_RC_SUCC if success.
See Also
For explanation of the possible date, time, and timestamp formats, see
“SaDateToAsciiz” on page 137.
SaSetSortBufSize
SaSetSortBufSize sets the amount of memory that a connection uses for local sorts
(sorts that are done on the client side by the SA library).
Synopsis
SaRetT SA_EXPORT_H SaSetSortBufSize(
SaConnectT* scon,
unsigned long size)
Note: The usage type includes "out" because the scon parameter is modified by
this function call.
Return Value
SaSetSortMaxFiles
SaSetSortMaxFiles sets the maximum number of files that the connection uses for
local sorts (sorts that are done on the client side by the SA library).
Synopsis
SaRetT SA_EXPORT_H SaSetSortMaxFiles(
SaConnectT* scon,
unsigned int nfiles)
Note: The usage type includes "out" because the scon parameter is modified by
this function call.
Return Value
SaSetTimeFormat
SaSetTimeFormat defines the default time format.
For an explanation of the possible formats, see the time portion documentation of
SaDateSetAsciiz in “SaDateSetAsciiz” on page 135.
Synopsis
SaRetT SA_EXPORT_H SaSetTimeFormat(
SaConnectT* scon,
char* timeformat)
Note: The usage type of scon includes "out" because the scon parameter is
modified by this function call.
Return Value
SA_RC_SUCC
See Also
For an explanation of the possible date, time, and timestamp formats, see
“SaDateSetAsciiz” on page 135.
For an explanation of the possible date, time, and timestamp formats, see
“SaDateSetAsciiz” on page 135.
Synopsis
SaRetT SA_EXPORT_H SaSetTimestampFormat(
SaConnectT* scon,
char* timestampformat)
Return Value
SA_RC_SUCC
See Also
For an explanation of the possible date, time, and timestamp formats, see
“SaDateSetAsciiz” on page 135.
SaSQLExecDirect
SaSQLExecDirect allows you to execute simple SQL statements such as CREATE
TABLE, DROP TABLE, INSERT, and DELETE.
You cannot do SELECT operations because it is not possible to fetch the data.
Synopsis
SaRetT SA_EXPORT_H SaSQLExecDirect(SaConnectT* scon,
char *sqlstr)
SA_RC_SUCC
SaTransBegin
SaTransBegin starts a new transaction. After this call, all select, insert, update and
delete operations are executed in the same transaction, and the changes are not
visible in the database until SaTransCommit is called.
Without the SaTransBegin call, the server is in autocommit mode by default and
therefore each select, insert, update, and delete operation is executed in a separate
transaction. No explicit commit (SaTransCommit) is required when in autocommit
mode.
The transaction is run in a mode where write operations are validated for lost
updates and unique errors.
Synopsis
void SA_EXPORT_H SaTransBegin(SaConnectT* scon)
Return Value
None.
SaTransCommit
SaTransCommit commits the current transaction started by SaTransBegin.
After calling this function, all changes are made persistent in the database. After
the current transaction is completed, the database server returns to autocommit
mode until the next call to SaTransBegin.
Synopsis
SaRetT SA_EXPORT_H SaTransCommit(SaConnectT* scon)
Return Value
SaTransRollback
SaTransRollback rolls back the current transaction started by SaTransBegin. No
changes are made to the database.
Synopsis
SaRetT SA_EXPORT_H SaTransRollback(SaConnectT* scon)
Return Value
SaUserId
SaUserID returns current user id of a connection.
Synopsis
int SA_EXPORT_H SaUserId(SaConnectT* scon)
Return Value
Starting from version 6.5, the solidDB databases can be created in two modes:
Unicode mode or partial Unicode mode. This database mode is based on the
encoding of character data types (CHAR, VARCHAR and so on) in the solidDB
server. Wide character data types (WCHAR, WVARCHAR and so on) are Unicode
encoded in both modes.
v Unicode mode
In the Unicode mode, the internal representation for character data types is
UTF-8.
The internal representation for wide character data types is UTF-16.
v partial Unicode mode
In the partial Unicode mode, the internal representation for character data types
uses no particular encoding; instead, the data is stored in byte strings with the
assumption that user applications are aware of this and handle the conversion as
necessary.
The internal representation for wide character data types is UTF-16.
The databases created with solidDB version 6.3 or earlier are of the partial
Unicode type.
Note: Unicode applications can be built on both Unicode and partial Unicode
databases. However, the instructions in this section assume that the Unicode
support is based on the Unicode database mode.
159
There are no non-standard or solidDB-specific requirements for application
development; standard ODBC API or JDBC API can be used.
What is Unicode?
The Unicode Standard is the universal character representation standard for text in
computer processing. Unicode provides a consistent way of encoding multilingual
plain text making it easier to exchange text files internationally.
The Unicode Standard defines code points (unique numbers) for characters used in
the major languages written today. This includes punctuation marks, diacritics,
mathematical symbols, technical symbols, arrows, dingbats, and so on. In all, the
Unicode Standard provides codes for over 100,000 characters from the world's
alphabets, ideograph sets, and symbol collections, including classical and historical
texts of many written languages. The characters can be represented in different
encoding forms, such as UTF-8 and UTF-16.
The Unicode Standard is fully compatible with the International Standard ISO/IEC
10646; it contains all the same characters and code points as ISO/IEC 10646. This
code-for-code identity is true for all encoded characters in the two standards,
including the East Asian (Han) ideographic characters. The Unicode Standard also
provides additional information about the characters and their use. Any
implementation that conforms to Unicode also conforms to ISO/IEC 10646.
Encoding forms
Unicode characters are represented in one of three encoding forms: a 32-bit form
(UTF-32), a 16-bit form (UTF-16), and an 8-bit form (UTF-8). These character
encoding standards define not only the identity of each character and its numeric
value (code position), but also how this value is represented in bits.
Starting from version 6.5, solidDB can be configured to use the UTF-8 encoding for
representing character data and UTF-16 encoding for wide character data. The
database mode is controlled with the parameter [Link].
The UTF-8 and UTF-16 encodings are essentially ways of turning the encoding into
the actual bits that are used in implementation; UTF-8 and UTF-16 encodings share
the same character set, but the data size of each character differs.
v UTF-16
UTF-16 assumes 16-bit characters and allows for a certain range of characters to
be used as an extension mechanism in order to access an additional million
characters using 16-bit character pairs.
Note: Unicode applications can be built on both Unicode and partial Unicode
databases. However, the instructions in this section assume that the Unicode
support is based on the Unicode database mode.
Important: The database mode must be defined when the database is created and
it cannot be changed later.
If the database already exists in either mode and the database mode contradicts the
value of the parameter, the server startup fails with the following error message in
the [Link]:
Parameter [Link] contradicts the existing database mode
Both character and wide character data types can be used to store Unicode data in
Unicode databases. If mainly multi-byte data is expected, you can optimize
space-efficiency by choosing to store the multi-byte data into wide character
column types. This is because even though UTF-8 and UTF-16 encodings share the
same character set, the data size of each character differs.
For example, Asian languages are stored more efficiently on wide character data
types (UTF-16) since most characters are part of BMP, which requires two bytes.
European languages are stored more efficiently on character data types (UTF-8)
since most common characters are represented in one byte.
Wide character data requires also less processing; using wide character data types
may improve performance.
The Unicode data types are interoperable; because UTF-16 and UTF-8 share the
same character set, there is no risk of data loss when using either data type. All
string operations are possible between character and wide character data types
with implicit type conversions.
In order to start storing Unicode data in a Unicode database, tables with Unicode
data columns need to be created first as follows:
CREATE TABLE customer1 (c_id INTEGER, c_name VARCHAR,...)
CREATE TABLE customer2 (c_id INTEGER, c_name WVARCHAR,...)
The character data columns are ordered based on the binary values of the UTF-8
and wide character data columns on the UTF-16 format (using most significant
byte order). If the binary order is different than what the national language users
expect, you need to provide a separate column to store the correct ordering
information.
solidDB tools can handle Unicode strings according to the default locale of the
environment or according to a specified locale.
For more details, see “Using solidDB tools with Unicode” on page 163.
User names and passwords can also be Unicode strings. However, to avoid access
problems from different tools, the original database administrator account
information must be given as pure ASCII strings.
The following solidDB tools can be used to output and import data in the system
default locale or a specified locale in both Unicode and partial Unicode databases.
v solidDB SQL Editor (solsql)
v solidDB Data Dictionary (soldd)
v solidDB Export (solexp)
v solidDB Speed Loader (solloado)
solidDB Remote Control (solcon) does not support conversions of data to UTF-8.
For example, if an error message that is output to solcon contains Unicode
encoded data, it is not displayed correctly in the console.
The locale to be used in conversions is defined with the command line options
when starting the tool.
Important:
v The solidDB tools use the solidDB ODBC API 3.5.1; this means that if the
binding method for character data types is defined with the server-side
[Link] or client-side [Link] parameters,
this setting also impacts the behavior of the solidDB tools.
v The Unicode and partial Unicode databases behave differently in reference to
conversions of CHAR and WCHAR data types:
– Unicode databases
Both CHAR and WCHAR data types are converted between the
UTF-8/UTF-16 format in solidDB and the locale/codepage defined with the
chosen binding method.
– partial Unicode databases
CHAR data types are not converted; instead, they are handled in the raw
(binary) format that is used to store CHAR data in partial Unicode databases.
WCHAR data types are converted between the UTF-16 format in solidDB and
the locale/codepage defined with the chosen binding method.
For example, in Linux environments, the locale name for the code
page GB18030 in Chinese/China is zh_CN.gb18030.
Note: If the server-side or client-side parameters in the [Link] file are set to use
'Raw' binding, you should always use the -m, -M or -u option to override the
[Link] settings.
If the database already exists in either mode and the database mode contradicts the
value of the parameter, the server startup fails with the following error message in
[Link].
Parameter [Link] contradicts the existing database mode
Tip: If you have your database creation scripts available, you can use them to
create the new database table definitions, instead of using soldd and solsql for
exporting and importing them.
Procedure
1. Extract data definitions with solidDB Data Dictionary (soldd).
Use the following command to extract an SQL script containing definitions for
all tables, views, triggers, indexes, procedures, sequences, and events.
soldd -Mzh_CN.gb18030 "tcpip 1964" dbadmin password
The default file name [Link] is used.
Note: User and role definitions are not listed for security reasons. If the
database contains users or roles, add CREATE statements for them to the
extracted SQL file manually.
Supported interfaces
v ODBC
The solidDB ODBC Driver is Unicode compliant; it conforms to the Microsoft
ODBC 3.51 standard.
Note: solidDB provides two versions of the ODBC driver, one for Unicode and
one for ASCII. The Unicode version is a superset of the ASCII version; you can
use it with either Unicode or ASCII character sets.
v JDBC
Unicode is supported in the solidDB JDBC Driver which is a solidDB
implementation of the JDBC 2.0 standard.
As Java uses natively Unicode strings, supporting Unicode means primarily that
when accessing character data in solidDB, no data type conversions are
necessary. Additionally, JDBC ResultSet Class methods getUnicodeStream and
setUnicodeStream are supported for handling large Unicode texts stored in
solidDB.
In Unicode databases, the solidDB ODBC and JDBC drivers handle the conversion
of data between the application encoding and the UTF-8/UTF-16 format in the
solidDB server.
SQL string functions work as expected. Conversions are provided implicitly, when
necessary. If either of the operands is of wide character type, the result is always of
wide character type.
As of 6.5 Fix Pack 10, the functions UPPER() and LOWER() perform the uppercase
or lowercase conversions for all Unicode characters in Unicode databases
([Link]=UTF8). In versions prior to 6.5 Fix Pack 10,
conversions are supported only when the characters are part of Latin 1 code page.
If the Unicode character cannot be converted to uppercase or lowercase, the input
string is returned as it is.
For binding of character data, you can set the ODBC driver to use one of the
following methods:
v the current client locale encoding
v specific encoding as defined with a locale name
v no encoding
v UTF-8 encoding
Note:
v If the value in [Link] is other than locale, it overrides
any current system locale setting for all clients.
v If the value in [Link] is other than locale, it overrides both
the server side value (if set) and the current system locale setting.
Note: Setting a specific locale overrides the application settings defined with
setlocale().
All clients use the current locale of the client. Different clients can use different
code pages.
Example 2
Some clients use the current locale of the client, some clients use Latin1 code page:
In those clients that require the Latin1 code page, the client-side [Link] is used:
[Client]
ODBCCharBinding=locale:fin_fin.1252
The Log Reader is based on a read-only system table called SYS_LOG where each
row corresponds to a single log entry. The SYS_LOG table is a virtual table: when
the Log Reader receives an SQL request for the SYS_LOG table, the appropriate
result set is generated dynamically from the internal log structures. Each log read
can be started from different log record.
For each entry in the transaction log, the SYS_LOG table contains data for
identifying the log record, the type of transaction and statement executed, as well
as the row with the changed data itself.
The SYS_LOG table can be accessed with ODBC and JDBC drivers using SQL
statements. For example, an application could be written to read the solidDB
transaction log and extract records pertaining to SQL DML statements. The
application could then reconstruct the statements into plain text SQL strings and
print them to a desired type of output.
Applications can read the SYS_LOG table both locally and remotely. Several
applications can read the SYS_LOG table concurrently without interference.
A sample application that demonstrates the use of the Log Reader interface is
included in the solidDB package, available in samples/logreader directory.
For a detailed description of the SYS_LOG table, see the section SYS_LOG in the
Appendix Database virtual tables in the IBM solidDB SQL Guide.
171
v Cascading actions are supported.
Operations resulted from cascading referential actions are logged as normal user
operations. Cascading operations are logged after the actual user data operation.
v DDL operations are supported.
For DDL operations, the Log Reader will return a special
DBE_LOGREADER_LOG_REC_DDL record that contains the original SQL
statement.
When several Log Readers are used, each Log Reader has its own data mode.
In live data mode the cursor returns every second even if there is no data
available. In that case, the FLAGS field in the SYS_LOG table is zero.
Primary keys
Primary key is not mandatory for the tables. System generated internal and hidden
primary key value is not returned through the Log Reader.
When designing your database, you must decide how rows are identified if
primary key is not defined.
High Availability
High Availability (HotStandby) is supported so that the log file contents and log
address are compatible between Primary and Secondary servers. If the log is read
from Primary server and there is a failover, a new read from SYS_LOG can be
started using the last LOGADDR received from the old Primary server.
The log can be read also from the Secondary server. This can useful, for example,
for load balancing reasons.
Throttling
If the server can generate log records faster than the client can read, throttling can
occur. This means that user transactions writing to the server are slowed down to
make sure the Log Readers are not too much behind the live data. The
[Link] parameter can be used to control the buffering after which
throttling can occur.
Applications that start a read but then stop reading can also cause the server to
stop.
If the application using the Log Reader is stopped or terminated for longer time, a
the log maximum size may be reached. In such a case, no error message is
Access rights
Administrator rights are needed to access the SYS_LOG table, to add tables to a
partition or to remove tables from a partition.
The log reading can be stopped at any time. No data is lost even of some
undelivered data are left in the log.
The log reading may be resumed without any loss of information if the last read
position is known. By using the current log position, the application will be able to
continue reading the log, without any loss of data, upon the next SYS_LOG query.
If the SYS_LOG table is accessed without specifying the log position, the reading
starts from the live data.
The Log Reader can be stopped in the solidDB server with the ADMIN COMMAND
’LOGREADER STOP’ command.
Procedure
v Enable the Log Reader by setting LogReaderEnabled to 'yes'.
This enables the Log Reader, allowing reads from SYS_LOG. The transaction
logging mode is also more verbose.
v As necessary for your environment, set the following parameters:
– Set MaxSpace value to define the maximum number of log records buffered
into memory before throttling occurs.
– Set MaxLogSize value to define the maximum size of the log available for a
catchup.
When the log reaches the defined size, old log data is deleted and catchup is
not possible from the older LOGADDR log positions.
– Set MaxMemLogSize value to define the maximum size of the Log Reader logfile
in memory, when logging is not enabled ([Link]=No).
Example
[LogReader]
LogReaderEnabled=yes ;Default: no
;
;MaxLogSize=100000 ;default: 10240 (MB)
; The amount of the log files (in MB) that will be always maintained
; for the sake of a possible catchup. The size should be adjusted to
; the biggest size of a catchup that is reasonable. The space declared
; is always fully occupied.
The transaction log can be read by multiple concurrently active SELECT statements
at the same time. Each log read can be started from different log position,
independently from the others.
Tip:
The solidDB package contains a sample application that demonstrates the use of
the Log Reader interface. The sample application is available in the
samples/logreader directory in the solidDB installation directory.
Procedure
1. Read log data from the SYS_LOG table with a SELECT statement.
The basic syntax to read log is:
SELECT RECID, RELID, FLAGS, LOGADDR, DATA FROM SYS_LOG WHERE LOGADDR > ?;
The WHERE condition is allowed only for LOGADDR field. Only constraint that is
allowed is greater than (>). Constraints to other fields will result in an error.
Alternatively, you can start the log read from a specified log position, defined
with the LOGADDR field.
a. Retrieve the current LOGADDR value.
SELECT LOGADDR FROM SYS_LOG LIMIT 1;
For example:
SELECT LOGADDR FROM SYS_LOG LIMIT 1;
LOGADDR
-------
0000000000000001FFFFFFFF0000029500000295
1 rows fetched.
b. Define the LOGADDR in the SELECT statement.
For example:
SELECT RECID,RELID,FLAGS,LOGADDR,DATA FROM SYS_LOG WHERE LOGADDR > ’0000000000000001FFFFFFFF0000029500000295’;
ResultWhen a read is started, the fetch calls will start returning rows. The user
data for the log record is included in the DATA column in binary format.
When no data is available, the server will return empty data in one second
intervals. In such a case, you can issue a new fetch call to see if new data is
available.
For more details on the DATA column and other columns in the SYS_LOG
table, see SYS_LOG table definition in the IBM solidDB SQL Guide.
2. Reconstruct the user data in the rows returned by the Log Reader.
Procedure
v Creating partitions
Create partitions with the following command:
CREATE LOGREADER PARTITION <partition-name>
v Deleting partitions
Delete (drop) partitions with the following command:
DROP LOGREADER PARTITION <partition-name>
v Modifying partitions
Add or remove tables from a partition with the following command:
ALTER LOGREADER PARTITION <partition-name> {ADD | DROP} TABLE <table-name>
The setting for the partition filter applies only to the current session and is valid
for all reads from SYS_LOG that are started after the setting. The partition data is
Procedure
v Set partition filters with the following statement:
SET LOGREADER PARTITION { <partition-name> | NONE }
When set to NONE (default), all log records are read.
v View the existing partitions in the SYS_FEDT_DB_PARTITION system table with
a SELECT statement.
For example:
SELECT * FROM sys_fedt_db_partition
The transaction batch setting applies only to the current session and is valid for all
reads from SYS_LOG that are started after the setting.
Procedure
Results
Setting the batch transaction size does not alter the catchup position; the catchup
position can be used to read all transaction in the batch again.
SQLAllocHandle (3.0) Returns the list of supported data source Supported ISO 92 ODBC
attributes.
Supported
Returns the list of installed drivers and their
attributes.
SQLDriverConnect (1.0) This function is an alternative to SQLConnect. Supported (including Unicode ODBC
It supports data sources that require more version of this function).
connection information than the three
arguments in SQLConnect, including dialog
boxes to prompt the user for all connection
information, and data sources that are not
defined in the system information.
SQLBrowseConnect (1.0) Returns successive levels of attributes and Not supported ISO 92
attribute values. When all levels have been
enumerated, a connection to the data source
is completed and a complete connection
string is returned. A return of
SQL_SUCCESS_WITH_INFO indicates that all
connection information has been specified
and the application is now connected to the
data source.
SQLGetInfo (1.0) Returns general information about the driver Supported ISO 92
and data source associated with a connection.
177
Table 142. solidDB supported ODBC functions (continued)
SQLGetFunctions (1.0) Returns information about whether a driver Supported; this function is ISO 92
supports a specific ODBC function. implemented in the ODBC
Driver Manager. It can also be
implemented in drivers. If a
driver implements
SQLGetFunctions, the Driver
manager calls the function in
the driver. Otherwise, it
executes the function itself. In
the case of solidDB, the
function is implemented in
the driver so that the
application linked to the
driver can also call this
function from the application.
SQLDataSources (1.0) Returns information about a data source. Supported; this function is ISO 92
implemented in the ODBC
Driver Manager.
SQLDrivers (2.0) Lists driver descriptions and driver attribute Supported; this function is ODBC
keywords. implemented in the ODBC
Driver Manager.
SQLGetCursorName (1.0) Returns the cursor name associated with a Supported ISO 92
statement handle.
SQLSetCursorName (1.0) Supported ISO 92
Specifies a cursor name with an active
statement. If an application does not call
SQLSetCursorName, the driver generates
cursor names as needed for SQL statement
processing.
SQLSetScrollOptions (1.0) Sets options that control cursor behavior. Deprecated (replaced by ODBC
SQLGetInfo and
SQLSetStmtAttr)
Submitting Requests
SQLNativeSQL (1.0) Returns the SQL string as modified by the Not implemented; solidDB N/A
driver. SQLNativeSQL does not execute the does not support this
SQL statement. functionality.
SQLDescribeCol (1.0) Returns the result descriptor (column name, Supported. ISO 92
type, column size, decimal digits, and
nullability) for one column in the result set.
This information is also available in the fields
of the IRD.
SQLBindCol (1.0) Assigns storage for a result column and Supported ISO 92
specifies the data type.
SQLFetch (1.0) Returns multiple result rows, fetching the Supported ISO 92
next rowset of data from the result set and
returning data for all bound columns.
SQLFetchScroll (3.0) Returns scrollable result rows, fetching the Supported ISO 92
specified rowset of data from the result set Note: Since the solidDB
and returning data for all bound columns. ODBC Driver currently has no
Block cursor support enables an application support for bookmarks, it is
to fetch more than one row with a single not possible to support the
fetch into the application buffer. SQL_FETCH_BOOKMARK
option in SQLFetchScroll.
When working with an ODBC 2.x driver, the
Driver Manager maps this function to
SQLExtendedFetch.
SQLGetData (1.0) Returns part or all of one column of one row Supported ISO 92
of a result set. It can be called multiple times
to retrieve variable length data in parts,
making it useful for long data values.
SQLSetPos (1.0) Positions a cursor within a fetched block of Supported, along with all the ODBC
data and allows an application to refresh data options, that is,
in the rowset or to update or delete data in
the result set. SQL_POSITION,
SQL_DELETE, and
SQL_UPDATE
SQLBulkOperations (3.0) Performs bulk insertions and bulk bookmark solidDB supports this, but ODBC
operations, including update, delete, and only when using the
fetch by bookmark. SQL_ADD option.
SQLMoreResults (1.0) Determines whether there are more results Not supported ODBC
available on a statement containing SELECT,
UPDATE, INSERT, or DELETE statement and, solidDB does not support
if so, initializes processing for those results. multiple results.
SQLPrimaryKeys (1.0) Returns the list of column names that make Supported ODBC
up the primary key for a table. The driver
returns the information as a result set. This
function does not support returning primary
keys from multiple tables in a single call.
SQLProcedureColumns (1.0) Returns the list of input and output Supported. ODBC
parameters, as well as the columns that make
up the result set for the specified procedures.
The driver returns the information as a result
set on the specified statement.
SQLProcedures (1.0) Returns the list of procedure names stored in Supported ODBC
a specific data source. Procedure is a generic
term used to describe an executable object, or
a named entity that can be invoked using
input and output parameters.
SQLStatistics (1.0) Returns statistics about a single table and the Supported ISO 92
list of indexes associated with the table. The
driver returns the information as a result set.
SQLTablePrivileges (1.0) Returns a list of tables and the privileges Supported ODBC
associated with each table. The driver returns
the information as a result set on the
specified statement.
SQLTables (1.0) Returns the list of table, catalog, or schema Supported X/Open
names, and table types, stored in a specific
data source.
Terminating a statement
SQLCloseCursor (3.0) Closes a cursor that has been opened on a Supported ISO 92
statement, and discards pending results.
Terminating a Connection
1
Version introduced is the version when the function was first added to the ODBC
API.
2
Conformance level can be:
v ISO 92 (also appears in X/Open version 1 because X/Open is a pure superset of
ISO 92)
v X/Open (also appears in ODBC 3.x because ODBC 3.x is a pure superset of
X/Open version 1)
SQL_ATTR_ SQL_CP_OFF All values are All values are not All values are not
CONNECTION_ supported applicable to the applicable to
POOLING SQL_CP_ driver ODBC drivers,
ONE_PER_DRIVER handled by Driver
Manager, so this
SQL_CP_ attribute will be
ONE_PER_HENV supported if the
application links to
ODBC DM and
can't be simulated
by the driver itself.
SQL_ATTR_CP_MATCH SQL_CP_ All values All values are not All values are not
STRICT_MATCH supported applicable to the applicable to
driver ODBC drivers,
SQL_CP_ handled by Driver
RELAXED_MATCH Manager, so this
attribute will be
supported if the
application links to
ODBC DM and
can't be simulated
by the driver itself.
187
Table 144. 002 Connection Level
SQL_CUR_USE_ODBC
SQL_CUR_
USE_DRIVER
SQL_MODE_
READ_WRITE
SQL_ASYNC_
ENABLE_ON
SQL_ATTR_
AUTOCOMMIT_ON
SQL_ATTR_TXN_ISOLATION SQL_TXN_ All values are All values are An solidDB server
SERIALIZABLE supported, except supported, except does not support
the
SQL_TXN_READ_ SQL_TXN_ SQL_TXN_
UNCOMMITTED READ_ READ_ READ_
UNCOMMITTED UNCOMMITTED UNCOMMITTED
SQL_TXN_READ_ feature.
COMMITTED
SQL_TXN_
REPEATABLE_
READ
Driver Driver
Attribute Value (Option) Manager Alone Comments
SQL_CONCUR_VALUES
SQL_ATTR_MAX_LENGTH Length in bytes Not Not Whatever the length, sets only
supported supported to default (0).
SQL_ATTR_MAX_ROWS Maximum number of rows Not Not Whatever the length, sets only
supported supported to default (0).
Driver Driver
Attribute Value (Option) Manager Alone Comments
SQL_ROWSET_SIZE Number of rows to return Supported Supported Allows the ODBC application
to set its value to greater than
1.
SQL_ATTR_ SQL_SC_NON_UNIQUE All values All values All values are not relevant to
SIMULATE_CURSOR not not solidDB Driver
SQL_SC_TRY_UNIQUE supported supported
SQL_SC_UNIQUE
Driver Driver
Attribute Value (Option) Manager Alone Comments
Not Not
supported supported
SQL_ATTR_ROW_NUMBER Number of current row Supported Supported User can get the number of
rows; cannot set because of
read-only property
SQL_DESC_
OCTET_LENGTH_PTR
SQL_DESC_
BIND_OFFSET_PTR
Driver Driver
Attribute Value (Option) Manager Alone Comments
Value
Attribute (Option) Driver Manager Driver Alone Comments
SQL_DESC_NAME
Value
Attribute (Option) Driver Manager Driver Alone Comments
01, 07, 08, 21, 22, 23, 24, 25, 28, 34, 3C, 3D, Indicates an error that includes a return
3F, 40, 42, 44, HY value of SQL_ERROR.
Note: Error class 01 returns both warnings
and errors.
SQLSTATE codes
Table 148. SQLSTATE codes
SQLGetDiagField
SQLGetDiagRec
SQLExecute
SQLParamData
SQLSetPos
195
Table 148. SQLSTATE codes (continued)
SQLParamData
v SQLColAttribute
01004 String data, right truncated
v SQLDataSources
v SQLDescribeCol
v SQLDriverConnect
v SQLDrivers
v SQLExecDirect
v SQLExecute
v SQLExtendedFetch
v SQLFetch
v SQLFetchScroll
v SQLGetConnectAttr
v SQLGetCursorName
v SQLGetData
v SQLGetDescField
v SQLGetDescRec
v SQLGetEnvAttr
v SQLGetInfo
v SQLGetStmtAttr
v SQLParamData
v SQLPutData
v SQLSetCursorName
SQLExecute
SQLParamData
SQLExecute
SQLParamData
v SQLConnect
01S02 Option value changed
v SQLDriverConnect
v SQLExecDirect
v SQLExecute
v SQLParamData
v SQLPrepare
v SQLSetConnectAttr
v SQLSetDescField
v SQLSetEnvAttr
v SQLSetStmtAttr
SQLExecute
SQLExtendedFetch
SQLFetch
SQLFetchScroll
SQLGetData
SQLParamData
SQLSetPos
SQLExecute
SQLExecute
SQLParamData
SQLExecDirect
SQLExecute
SQLExtendedFetch
SQLFetch
SQLFetchScroll
SQLGetData
SQLParamData
SQLPutData
SQLBindParameter
SQLColAttribute
SQLDescribeCol
SQLDesribeParam
SQLFetch
SQLFetchScroll
SQLGetData
SQLGetDescField
SQLParamData
SQLSetDescField
SQLSetDescRec
SQLSetPos
SQLParamData
SQLPutData
SQLDriverConnect
SQLSetConnectAttr
SQLDisconnect
SQLEndTran
SQLGetConnectAttr
SQLGetInfo
SQLSetConnectAttr
v SQLColumnPrivileges
08S01 Communication link failure
v SQLColumns
v SQLConnect
v SQLConnect
v SQLCopyDesc
v SQLDescribeCol
v SQLDescribeParam
v SQLDriverConnect
v SQLExecDirect
v SQLExecute
v SQLExtendedFetch
v SQLFetch
v SQLFetchScroll
v SQLForeignKeys
v SQLGetConnectAttr
v SQLGetData
v SQLGetDescField
v SQLGetDescRec
v SQLGetFunctions
v SQLGetInfo
v SQLGetTypeInfo
v SQLMoreResults
v SQLNumParams
v SQLNumResultCols
v SQLParamData
v SQLPrepare
v SQLPrimaryKeys
v SQLProcedureColumns
v SQLProcedures
v SQLPutData
v SQLSetConnectAttr
v SQLSetDescField
v SQLSetDescRec
v SQLSetEnvAttr
v SQLSetStmtAttr
v SQLSpecialColumns
v SQLStatistics
v SQLTablePrivileges
v SQLTables
SQLParamData
SQLPrepare
SQLSetPos
SQLExecute
SQLFetch
SQLFetchScroll
SQLParamData
SQLPutData
SQLSetDescField
SQLSetPos
SQLExtendedFetch
SQLFetch
SQLFetchScroll
SQLGetData
SQLParamData
SQLExecute
SQLExtendedFetch
SQLFetch
SQLFetchScroll
SQLGetData
SQLGetInfo
SQLParamData
SQLPutData
SQLSetPos
SQLExecute
SQLExtendedFetch
SQLFetch
SQLFetchScroll
SQLGetData
SQLParamData
SQLPutData
SQLSetPos
SQLExecute
SQLParamData
SQLPutData
SQLExecute
SQLExtendedFetch
SQLFetch
SQLFetchScroll
SQLGetData
SQLParamData
SQLPutData
SQLExecute
SQLExtendedFetch
SQLFetch
SQLFetchScroll
SQLGetData
SQLParamData
SQLPutData
SQLSetPos
SQLExtendedFetch
SQLFetch
SQLFetchScroll
SQLGetData
SQLParamData
SQLPutData
SQLSetPos
SQLExecute
SQLPrepare
SQLExecute
SQLPrepare
SQLExecute
SQLParamData
SQLSetPos
SQLColumnPrivileges
SQLColumns
SQLExecDirect
SQLExecute
SQLExtendedFetch
SQLFetch
SQLFetchScroll
SQLForeignKeys
SQLGetData
SQLGetStmtAttr
SQLGetTypeInfo
SQLPrepare
SQLPrimaryKeys
SQLProcedureColumns
SQLProcedures
SQLConnectAttr
SQLSetCursorName
SQLSetPos
SQLSpecialColumns
SQLStatistics
SQLTablePrivileges
SQLTables
SQLPrepare
SQLSetCursorName
SQLPrepare
SQLSetConnectAttr
SQLPrepare
SQLColumns
SQLEndTran
SQLExecDirect
SQLExecute
SQLFetch
SQLFetchScroll
SQLForeignKeys
SQLGetTypeInfo
SQLMoreResults
SQLParamData
SQLPrimaryKeys
SQLProcedureColumns
SQLProcedures
SQLSetPos
SQLSpecialColumns
SQLStatistics
SQLTablePrivileges
SQLTables
SQLExecDirect
SQLExecute
SQLFetch
SQLFetchScroll
SQLGetTypeInfo
SQLForeignKeys
SQLMoreResults
SQLPrimaryKeys
SQLProcedureColumns
SQLProcedures
SQLParamData
SQLSetPos
SQLSpecialColumns
SQLStatistics
SQLTables
SQLParamData
SQLPrepare
SQLSetPos
SQLPrepare
SQLPrepare
SQLPrepare
SQLPrepare
SQLPrepare
SQLParamData
SQLGetDiagField
SQLGetDiagRec
SQLGetDiagField
SQLGetDiagRec
SQLGetData
SQLGetTypeInfo
SQLGetDescRec
HY008 Operation canceled All ODBC functions that can be processed asynchronously:
SQLColAttribute
SQLColumnPrivileges
SQLColumns
SQLDescribeCol
SQLDescribeParam
SQLExecDirect
SQLExecute
SQLExtendedFetch
SQLFetch
SQLFetchScroll
SQLForeignKeys
SQLGetData
SQLGetTypeInfo
SQLMoreResults
SQLNumParams
SQLNumResultCols
SQLParamData
SQLPrepare
SQLPrimaryKeys
SQLProcedureColumns
SQLProcedures
SQLPutData
SQLSetPos
SQLSpecialColumns
SQLStatistics
SQLTablePrivileges
SQLTables
SQLBindParameter
SQLColumnPrivileges
SQLColumns
SQLExecDirect
SQLForeignKeys
SQLGetCursorName
SQLGetData
SQLGetFunctions
SQLPrepare
SQLPrimaryKeys
SQLProcedureColumns
SQLProcedures
SQLPutData
SQLSetConnectAttr
SQLSetCursorName
SQLSetEnvAttr
SQLSetStmtAttr
SQLSpecialColumns
SQLStatistics
SQLTablePrivileges
SQLTables
v SQLAllocHandle
HY010 Function sequence error
v SQLBindCol
v SQLBindParameter
v SQLCloseCursor
v SQLColAttribute
v SQLColumnPrivileges
v SQLColumns
v SQLCopyDesc
v SQLDescribeCol
v SQLDescribeParam
v SQLDisconnect
v SQLEndTran
v SQLExecDirect
v SQLExecute
v SQLExtendedFetch
v SQLFetch
v SQLFetchScroll
v SQLForeignKeys
v SQLFreeHandle
v SQLFreeStmt
v SQLGetConnectAttr
v SQLGetCursorName
v SQLGetData
v SQLGetDescField
v SQLGetDescRec
v SQLGetFunctions
v SQLGetStmtAttr
v SQLGetTypeInfo
v SQLMoreResults
v SQLNumParams
v SQLNumResultCols
v SQLParamData
v SQLPrepare
v SQLPrimaryKeys
v SQLProcedureColumns
v SQLProcedures
v SQLPutData
v SQLRowCount
v SQLSetConnectAttr
v SQLSetCursorName
v SQLSetDescField
v SQLSetEnvAttr
v SQLSetDescRec
v SQLSetPos
v SQLSetStmtAttr
v SQLSpecialColumns
v SQLStatistics
v SQLTablePrivileges
v SQLTables
SQLSetConnectAttr
SQLSetPos
SQLSetStmtAttr
SQLGetDiagField
SQLGetDiagRec
SQLSetDescRec
SQLGetDescField
SQLSetDescField
SQLSetDescRec
SQLSetEnvAttr
SQLSetStmtAttr
v SQLBindCol
HY090 Invalid string or buffer
length v SQLBindParameter
v SQLBrowseConnect
v SQLColAttribute
v SQLColumnPrivileges
v SQLColumns
v SQLConnect
v SQLDataSources
v SQLDescribeCol
v SQLDriverConnect
v SQLDrivers
v SQLExecDirect
v SQLExecute
v SQLFetch
v SQLFetchScroll
v SQLForeignKeys
v SQLGetConnectAttr
v SQLGetCursorName
v SQLGetData
v SQLGetDescField
v SQLGetInfo
v SQLGetStmtAttr
v SQLParamData
v SQLPrepare
v SQLPrimaryKeys
v SQLProcedureColumns
v SQLProcedures
v SQLPutData
v SQLSetConnectAttr
v SQLSetCursorName
v SQLSetDescField
v SQLSetDescRec
v SQLSetEnvAttr
v SQLSetStmtAttr
v SQLSetPos
v SQLSpecialColumns
v SQLTablePrivileges
v SQLStatistics
v SQLTables
SQLSetDescField
SQLDriverConnect
SQLEndTran
SQLFreeStmt
SQLGetConnectAttr
SQLGetEnvAttr
SQLGetStmtAttr
SQLParamData
SQLSetConnectAttr
SQLSetDescField
SQLSetEnvAttr
SQLSetPos
SQLSetStmtAttr
SQLDrivers
SQLExecDirect
SQLExecute
SQLParamData
SQLSetDescField
SQLFetchScroll
SQLFetch
SQLFetchScroll
SQLSetPos
SQLExecute
SQLGetData
SQLGetStmtAttr
SQLParamData
SQLSetPos
SQLFetchScroll
v SQLBindCol
HYC00 Optional feature not
implemented v SQLBindParameter
v SQLColAttribute
v SQLColumnPrivileges
v SQLColumns
v SQLDriverConnect
v SQLEndTran
v SQLConnect
v SQLExecDirect
v SQLExecute
v SQLExtendedFetch
v SQLFetch
v SQLFetchScroll
v SQLForeignKeys
v SQLGetConnectAttr
v SQLGetData
v SQLGetEnvAttr
v SQLSetPos
v SQLGetInfo
v SQLGetStmtAttr
v SQLGetTypeInfo
v SQLParamData
v SQLPrepare
v SQLPrimaryKeys
v SQLProcedureColumns
v SQLProcedures
v SQLSetConnectAttr
v SQLSetEnvAttr
v SQLSetStmtAttr
v SQLSpecialColumns
v SQLStatistics
v SQLTablePrivileges
v SQLTables
SQLColumnPrivileges
SQLColumns
SQLConnect
SQLDriverConnect
SQLExecDirect
SQLExecute
SQLExtendedFetch
SQLForeignKeys
SQLGetTypeInfo
SQLParamData
SQLPrepare
SQLPrimaryKeys
SQLProcedureColumns
SQLProcedures
SQLSetPos
SQLSpecialColumns
SQLStatistics
SQLTablePrivileges
SQLTables
SQLDrivers
SQLDataSources
SQLGetEnvAttr
SQLSetEnvAttr
IM001 Driver does not support this All ODBC functions except:
function
SQLAllocHandle
SQLDataSources
SQLDrivers
SQLFreeHandle
SQLGetFunctions
SQLDriverConnect
SQLSetConnectAttr
SQLDriverConnect
Note: If the driver supports only read-only data sources, the SQL syntax that
applies to changing data may not apply to the driver. Applications need to call
SQLGetInfo with the SQL_DATA_SOURCE_READ_ONLY information type to
determine if a data source is read-only.
SQL statements
This section describes the subset of SQL statements and elements.
create-table-statement ::=
CREATE TABLE base_table_name
(column_identifier data_type [, column_identifier data_type]...)
217
column_identifier ::= user_defined_name
column_name ::= [table_name.]column_identifier
comparison_operator ::= < | > | <= | >= | = | <>
comparison_predicate ::= expression comparison_operator expression
data_type ::= character_string_type
(character_string_type is any data type for which the
""DATA_TYPE"" column in the result set returned by SQLGetTypeInfo
is either SQL_CHAR or SQLVARCHAR.)
digit ::= 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
dynamic_parameter ::= ?
expression ::= term | expression {+|-} term
factor ::= [+|-]primary
insert_value ::= dynamic_parameter | literal | NULL | USER
letter ::= lower_case_letter | upper_case_letter
literal ::= character_string_literal
lower_case_letter ::= a | b | c | d | e | f | g |
h | i | j | k | l | m | n | o | p | q | r | s |
t | u | v | w | x | y | z
order_by_clause ::= ORDER BY sort_specification [, sort_specification]...
primary ::= column_name | dynamic_parameter | literal | ( expression )
search_condition ::= boolean_term [OR search_condition]
select_list ::= * | select_sublist [, select_sublist]...
(select_list cannot contain parameters.)
select_sublist ::= expression
sort_specification ::= {unsigned_integer | column_name } [ASC | DESC]
table_identifier ::= user_defined_name
table_name ::= table_identifier
table_reference ::= table_name
table_reference ::= table_name [,table_reference]...
term ::= factor | term {*|/} factor
unsigned_integer ::= {digit}
upper_case_letter ::= A | B | C | D | E | F | G |
H | I | J | K | L | M | N | O | P | Q | R | S |
T | U | V | W | X | Y | Z
user_defined_name ::= letter[ digit | letter| _ ]...
For a more detailed description of these control statements, see the discussion on
stored procedures in the solidDB SQL Guide.
Table 149. Control Statements
variable := expression
Alternate syntax for assigning values to
variables.
boolean_expr
A boolean expression which evaluates to
"true" or "false". The expression can include
comparison operators, such as =, >, and <)
and logical operators and, or, and not.
statement_list
A valid procedure statement that executes as
a result of a boolean expression.
while
boolean_expr This loops while the expression is true. For
loop examples of valid parentheses use in WHILE
statement_list loops, see the discussion of stored
end loop procedures in solidDB SQL Guide.
leave
Leaves the innermost while loop and
continues executing the procedure from the
next statement after the keyword end loop.
if
boolean_expr Executes statement_list1 if boolean_expr is
then true; otherwise, executes statement_list2. For
statement_list1 examples of valid parentheses use in IF
else statements, see the discussion on stored
statement_list2 procedures in solidDB SQL Guide.
end if
if
boolean_expr1 If boolean_expr1 is true, executes
then statement_list1. If boolean_expr2 is true,
statement_list1 executes statement_list2. The statement can
elseif optionally contain multiple elseif statements
boolean_expr2 and also an else statement. For examples of
then valid parentheses use in IF statement, see
statement_list2 the discussion of stored procedures in
end if solidDB SQL Guide.
return
Returns the current values of output
parameters and exits the procedure. If a
procedure has a return row statement, return
behaves like return norow.
return row
Returns the current values of output
parameters and continues execution of the
procedure. Return row does not exit the
procedure and return control to the caller.
return norow
Returns the end of the set and exits the
procedure.
The following table describes how a data type is determined for several types of
parameters according to SQL-92 standards. For comprehensive information about
inferring the parameter type, see the SQL-92 specification.
Table 150. Determining Data Ttype for Several Types of Parameters
An expression used with IN Same as the first value or the result column
of the subquery
Parameter markers
For a comprehensive list and more details, see the SQL-92 specification.
Literals in ODBC
This section contains information that will help driver writers who are converting
a character string type to a numeric or interval type, or from a numeric or interval
type to a character string type.
These words do not constrain the minimum SQL grammar. The #define value
SQL_ODBC_KEYWORDS contains a comma-separated list of these keywords.
For a complete list of reserved keywords in several SQL standards and solidDB
ODBC API, see “Reserved Words” in IBM solidDB SQL Guide.
Table 151. List of Reserved Keywords
OF ON ONLY OPEN
YEAR ZONE
Each SQL data type corresponds to an ODBC C data type. Before returning data
from the data source, the driver converts it to the specified C data type. Before
sending data to the data source, the driver converts it from the specified C data
type.
For information about driver-specific SQL data types, see the driver's
documentation.
Drivers map data source-specific SQL data types to ODBC SQL data type
identifiers and driver-specific SQL data type identifiers. The
SQL_DESC_CONCISE_TYPE field of an implementation descriptor is where the
SQL data type is stored.
solidDB's ODBC driver does not support the following SQL_92 data types:
v BIT
v BIT_VARYING
v TIME_WITH_TIMEZONE
v TIMESTAMP_WITH_TIMEZONE
v NATIONAL_CHARACTER
C data types
ODBC defines the C data types and their corresponding ODBC type identifiers.
225
Note: Driver-specific C data types do not exist.
They also retrieve metadata about the result set from the driver so applications
know what type of C buffers to use for data storage. Applications use data type
identifiers to perform these tasks by calling these functions:
v To describe the C data type of application buffers, applications call
SQLBindParameter, SQLBindCol, and SQLGetData.
v To describe the SQL data type of dynamic parameters, applications call
SQLBindParameter.
v To retrieve the SQL data types of result set columns, applications call
SQLColAttribute and SQLDescribeCol.
v To retrieve the SQL data types of parameters, applications call
SQLDescribeParameter.
v To retrieve the SQL data types of various schema information, applications call
SQLColumns, SQLProcedureColumns, and SQLSpecialColumns.
v To retrieve a list of supported data types, applications call SQLGetTypeInfo.
A driver also returns the SQL data types when it describes the data types of
columns and parameters using the following functions:
v SQLColAttribute
v SQLColumns
v SQLDescribeCol
v SQLDescribeParam
v SQLProcedureColumns
v SQLSpecialColumns
Note:
For details on fields that store SQL data type values and characteristics, see “Data
type identifiers and descriptors” on page 238.
The following table is not a comprehensive list of SQL data types, but offers
commonly used names, ranges, and limits. A data source may only support some
SQL Type Identifier [1] Typical SQL Data Type [2] Typical Type Description
SQL_BIT BIT Single bit binary data. NOTE: solidDB does not
support BIT/SQL_BIT. [7]
SQL Type Identifier [1] Typical SQL Data Type [2] Typical Type Description
SQL_LONGVARBINARY LONG VARBINARY Variable length binary data. Maximum length is data
source-dependent. [3]
SQL_TYPE_DATE [8] DATE Year, month, and day fields, conforming to the rules
of the Gregorian calendar. (See “Constraints of the
gregorian calendar” on page 242.)
SQL_TYPE_TIME [8] TIME(p) Hour, minute, and second fields. Valid values for
hours are 00 to 23. Valid values for minutes are 00 to
59. Valid values for seconds are 00 to 61 (60 and 61
are to handle "leap seconds" (see
[Link] Precision p
indicates the precision of the seconds field.
SQL_TYPE_TIMESTAMP [8] TIMESTAMP(p) Year, month, day, hour, minute, and send fields, with
valid values as defined for the DATE and Time data
types.
Note:
[1] This is the value returned in the DATA_TYPE column by a call to SQLGetTypeInfo.
[2] This is the value returned in the NAME and CREATE PARAMS column by a call to SQLGetTypeInfo. The NAME column
returns the designation - for example, CHAR - while the CREATE PARAMS column returns a comma-separated list of creation
parameters such as precision, scale, and length.
[4] SQL_DECIMAL and SQL_NUMERIC data types differ only in their precision. The precision of a DECIMAL(p,s) is an
implementation-defined decimal precision that is no less than p, while the precision of a NUMERIC(p,s) is exactly equal to p.
[5] An application uses SQLGetTypeInfo or SQLColAttribute to determine if a particular data type or a particular column in a
result set is unsigned.
[6] Depending on the implementation, the precision of SQL_FLOAT can be either 24 or 53: if it is 24, the SQL_FLOAT data type is
the same as SQL_REAL; if it is 53, the SQL_FLOAT data type is the same as SQL_DOUBLE.
[7] The SQL_BIT data type has different characteristics than the BIT type in SQL-92.
Applications call SQLGetTypeInfo result set for a list of supported data types and
their characteristics for a given data source.
The example below shows the data types that SQLGetTypeInfo returns for a data
source; all data types under "DATA_TYPE" are supported in this data source.
The example below is divided into 3 sections so that it fits the width of a page. In
fact, it is all one example.
Table 153. Data types SQLGetTypeInfo returns (1)
AUTO_
CASE_ UNSIGNED_ FIXED_ PREC_ UNIQUE_ LOCAL_ TYPE_
(continued) SENSITIVE SEARCHABLE ATTRIBUTE SCALE VALUE NAME
SQL_
MINIMUM_ MAXIMUM_ SQL_DATA_ DATETIME_ NUM_ PREC_ INTERVAL_
(continued) SCALE SCALE TYPE SUB RADIX PRECISION
SQL_
MINIMUM_ MAXIMUM_ SQL_DATA_ DATETIME_ NUM_ PREC_ INTERVAL_
(continued) SCALE SCALE TYPE SUB RADIX PRECISION
[a] 16 digits, 1 decimal point, and an optional sign character for negative numbers
C data types
The solidDB ODBC Driver supports all C data types in keeping with the need for
character SQL type conversion to and from all C types.
Note: The data types specified in this column are not platform-
independent; they are examples.
// A portable way to declare a variable that will be bound to a column of
// type SQL FLOAT.
SQLFLOAT MySharedSQLFLOATVariable = 0.0;
// A non-portable way to declare a variable that will be bound to a column
// of type SQL INTEGER. This declaration works properly on most 32-bit
// platforms, but may fail on 64-bit platforms.
long int MySharedSQLINTEGERVariable = 0;
// Bind MySharedSQLFLOATVariable to column 1 of the result set.
SQLBindCol(..., 1, SQL_C_DOUBLE, &MySharedSQLFLOATVariable, ...);
// Bind MySharedSQLINTEGERVariable to column 2 of the result set.
SQLBindCol(..., 2, SQL_C_SLONG, &MySharedSQLINTEGERVariable, ...);
The C Type Identifier and the ODBC C Type do not always have similar names.
The C Type Identifier has a name based on the C language data type (for example,
"float"), while the ODBC C Typedef has a name that is based on the SQL data type.
Since C-language "float" corresponds to SQL "REAL", the table lists
"SQL_C_FLOAT" as the C Type Identifier that corresponds to the ODBC C Typedef
"SQLREAL".
Table 156. C vs ODBC Naming Correspondence
SQLFLOAT
struct tagDATE_STRUCT{
SQL_C_TYPE_DATE [c] SQL_DATE_STRUCT SQLSMALLINT year;
SQLUSMALLINT month;
SQLUSMALLINT day;
} DATE_STRUCT; [a]
struct tagTIME_STRUCT {
SQL_C_TYPE_TIME [c] SQL_TIME_STRUCT SQLUSMALLINT hour;
SQLUSMALLINT minute;[d]
SQLUSMALLINT second;[e]
}
struct tagTIMESTAMP_STRUCT {
SQL_C_TYPE_TIMESTAMP SQL_TIMESTAMP_STRUCT SQLSMALLINT year; [a]
[c] SQLUSMALLINT month; [b]
SQLUSMALLINT day; [c]
SQLUSMALLINT hour;
SQLUSMALLINT minute; [d]
SQLUSMALLINT second;[e]
SQLUINTEGER fraction;
}
[a] The values of the year, month, day, hour, minute, and second fields in the datetime C
data types must conform to the constraints of the Gregorian calendar. (See “Constraints of
the gregorian calendar” on page 242.)
[b] The value of the fraction field is the number of nanoseconds (billionths of a second)
and ranges from 0 through 999,999,999 (1 less than 1 billion). For example, the value of the
fraction field for a half-second is 500,000,000, for a thousandth of a second (one
millisecond) is 1,000,000, for a millionth of a second (one microsecond) is 1,000, and for a
billionth of a second (one nanosecond) is 1.
[c] In ODBC 2.x, the C date, time, and timestamp data types are SQL_C_DATE,
SQL_C_TIME, and SQL_C_TIMESTAMP.
[e] The precision and scale fields of the SQL_C_NUMERIC data type are never used for
input from an application, only for output from the driver to the application. When the
driver writes a numeric value into the SQL_NUMERIC_STRUCT, it will use its own
driver-specific default as the value for the precision field, and it will use the value in the
SQL_DESC_SCALE field of the application descriptor (which defaults to 0) for the scale
field. An application can provide its own values for precision and scale by setting the
SQL_DESC_PRECISION and SQL_DESC_SCALE fields of the application descriptor.
[f] The DECIMAL and NUMERIC data types take up more than one byte/character. The
data types will actually be declared as arrays based on the precision required for the
column. For example, a column of type SQL DECIMAL(10,4) might be declared as
SQL_DECIMAL[13] to take into account the 10 digits, the sign character, the decimal point
character, and the string terminator.
[i] solidDB does not support unsigned SQL data types. You may bind an unsigned C data
type to a signed SQL column, but you should not do this unless the values stored in the
SQL column and the C variable are within the valid range for both data types. For
example, since signed TINYINT columns hold values from -128 to +127, while unsigned
SQL_C_UTINYINT variables hold values from 0 to 255, you may only store values
between 0 and +127 in the column and bound variable if you want the values to be
interpreted properly.
typedef struct {
SQLUINTEGER dwLowWord;
SQLINTEGER sdwHighWord;
} SQLBIGINT
Because a 64-bit integer is aligned to the 8-byte boundary, be sure to align these
structures to an 8-byte boundary.
Note:
Drivers cannot always determine the correct default C type for these reasons:
v The DBMS may have promoted an SQL data type of a column or a parameter; in
this case, the driver is unable to determine the original SQL data type and
consequently, cannot determine the corresponding default C data type.
v The DBMS determined whether the data type of a column or parameter is
signed or unsigned; in this case, the driver is unable to determine this for a
particular SQL data type and consequently, cannot determine this for the
corresponding default C data type.
SQL_C_TCHAR
The SQL_C_TCHAR type identifier is used for Unicode purposes. Use this
identifier in applications that transfer character data and are compiled to use both
ASCII and Unicode character sets. Note that the SQL_C_TCHAR is not a type
identifier in the conventional sense; instead, it is a macro contained in the header
file for Unicode conversion. SQL_C_CHAR or SQL_C_WCHAR replaces
SQL_C_TCHAR depending on the setting of the UNICODE #define.
Numeric literal syntax specifies what is stored in the target during the following
conversions:
v SQL data to an SQL_C_CHAR string
v C data to an SQL_CHAR or SQL_VARCHAR string
The syntax also validates what is stored in the source during the following
conversions:
v numeric stored as an SQL_C_CHAR string to numeric SQL data
v numeric stored as an SQL_CHAR string to numeric C data
Conversion Rules
The following rules apply to conversions involving numeric literals. Following are
terms used in this topic:
Table 157. Conversions Involving Numeric Literals
Term Meaning
Scale of an exact numeric Number of digits to the right of the expressed or implied
literal decimal point.
Following are the rules for converting from a character source (CS) to a numeric
target (NT):
1.
Replace CS with the value obtained by removing any leading or trailing spaces
in CS. If CS is not a valid numeric-literal, SQLSTATE 22018 (Invalid character
value for cast specification) is returned.
2.
Replace CS with the value obtained by removing leading zeroes before the
decimal point, trailing zeroes after the decimal point, or both.
3.
Convert CS to NT. If the conversion results in a loss of significant digits,
SQLSTATE 22003 (Numeric value out of range) is returned. If the conversion
results in the loss of nonsignificant digits, SQLSTATE 01S07 (Fractional
truncation) is returned.
Following are the rules for converting from a numeric source (NS) to a character
target (CT):
1.
Let LT be the length in characters of CT.
For retrieval assignment, LT is equal to the length of the buffer in characters
minus the number of bytes in the null-termination character for this character
set.
2.
Take one of the following actions depending on the type of NS.
v
If NS is an exact numeric type, then let YP equal the shortest character string
that conforms to the definition of exact-numeric-literal such that the scale of
YP is the same as the scale of NS, and the interpreted value of YP is the
absolute value of NS.
v
If NS is an approximate numeric type, then let YP be a character string as
follows:
Case:
a. If NS is equal to 0, then YP is the string "0".
b. Let YSN be the shortest character string that conforms to the definition of
exact-numeric-literal and whose interpreted value is the absolute value of
NS. If the length of YSN is less than the (precision + 1) of the data type of
NS, then let YP equal YSN.
c. Otherwise, YP is the shortest character string that conforms to the definition
of approximate-numeric-literal whose interpreted value is the absolute value
of NS and whose mantissa consists of a single digit that is not '0', followed
by a period and an unsigned-integer.
3. If NS is less than 0, then let Y be the result of:
’-’ || YP
where '||' is the string concatenation operator.
Otherwise, let Y equal YP.
4.
Let LY be the length in characters of Y.
[a] If the defaults are not acceptable for an application, the application can call the
SQLSetDescField or SQLSetDescRec to set the SQL_DESC_SCALE or
SQL_DESC_PRECISION field.
[b] If the defaults are not acceptable, the application must call SQLSetDescRec or
SQLSetDescField to set the fields and then call SQLGetData with a TargetType of
SQL_ARD_TYPE to use the values in the descriptor fields.
The exception, however, is the datetime and interval data types. For these data
types:
v SQL_DESC_TYPE contains the verbose type (SQL_DATETIME)
v SQL_DESC_CONCISE_TYPE contains a concise type
For details on setting fields and a setting's effect on other fields, see the
SQLSetDescField function description on the Microsoft ODBC web site.
Note: If the default values set are not appropriate, you can explicitly set the
descriptor field in the application by calling SQLSetDescField.
The following table lists for each SQL and C type identifier, the concise type
identifier, verbose identifier, and type subcode for each datetime.
For datetime data types, the SQL_DESC_TYPE have the same manifest constants
for both SQL data types (in implementation descriptors) and for C data types (in
application descriptors):
Table 159. Concise Type Identifier, Verbose Identifier, and Type Subcode for Each Datetime
DATETIME_INTERVAL_CODE
Concise SQL Type Concise C Type Verbose Type (also called "type subcode")
Pseudo-type identifiers
Because the number of digits to the right of the decimal point is not fixed, the
scale is undefined for approximate floating-point number columns or parameters.
When datetime data contains a seconds component, the decimal digits are the
number of digits to the right of the decimal point in the seconds component of the
data.
Typically, the maximum scale matches the maximum precision for SQL_DECIMAL
and SQL_NUMERIC data types. Some data sources, however, have their own
maximum scale limit. An application can call SQLGetTypeInfo to determine the
minimum and maximum scales allowed for a data type.
Note: The SQLBindParameter sets the decimal digits for a parameter in an SQL
statement.
The values returned by ODBC functions for decimal digits correspond to "scale" as
defined in ODBC 2.x.
Descriptor fields describe the characteristics of a result set. They do not contain
valid data values before statement execution. However, the decimal digits values
returned by SQLColumns, SQLProcedureColumns, and SQLGetTypeInfo, do
represent the characteristics of database objects, such as table columns and data
types form the data source's catalog.
Each concise SQL data type has the following decimal digits definition as noted in
the following table:
For decimal digits, the values returned do not correspond to the values in any one
descriptor field. The values returned (for example, in SQLColAttribute) for the
decimal digits can come from either the SQL_DESC_SCALE or the
SQL_DESC_PRECISION field, depending on the data type, as shown in the
following table:
Table 162. Descriptor field corresponding to decimal digits
For character data, space for the null-termination character is not included in the
transfer octet length. Note that the transfer octet length in bytes can differ from the
number of bytes needed to store the data on the data source.
The values returned by ODBC functions for the transfer octet length may not
correspond to the values returned in SQL_DESC_LENGTH. For all character and
binary types, the values come from a descriptor field's
SQL_DESC_OCTET_LENGTH. For other data types, there is no descriptor field
that stores this information.
Descriptor fields describe the characteristics of a result set. They do not contain
valid data values before statement execution. In its result set, SQLColAttribute
returns the transfer octet length of columns at the data source; these values may
not match the values in the SQL_DESC_OCTET_LENGTH descriptor fields. For
more information about descriptor fields, see SQLSetDescField function description
on the Microsoft ODBC Web site.
Each concise SQL data type has the following transfer octet length definition as
noted in the table below.
Table 164. Transfer Octet Lengths
All character and binary The defined or the maximum (for variable type) length of the
types [a] column in bytes. This value matches the one in the
SQL_DESC_OCTET_LENGTH descriptor field.
SQL_TINYINT 1
SQL_SMALLINT 2
SQL_INTEGER 4
SQL_REAL 4
SQL_FLOAT 8
SQL_DOUBLE 8
All binary types [a] The number of bytes required to store the defined (for fixed
types) or maximum (for variable types) number of characters.
[a] SQL_NO_TOTAL is returned when the driver cannot determine the column or
parameter length for variable types.
Value Requirement
day field Range must be from 1 through the number of days in the
month, which is determined from the values of the year and
months fields and can be 28, 29, 30, or 31. A leap year can
also affect the number of days in the month.
Value Requirement
trailing seconds field Must be between 0 and 61.9(n), inclusive, where n specifies
the number of digits at the place of "9" and the value of n is
the fractional seconds precision. The range of seconds permits
a maximum of two leap seconds to maintain synchronization
of sidereal time.
The following table shows the supported conversions from ODBC SQL data types
to ODBC C data types. A solid circle indicates the default conversion for an SQL
data type (the C data type to which the data will be converted when the value of
TargetType is SQL_C_DEFAULT). A hollow circle indicates a supported conversion.
For an ODBC 3.x application working with an ODBC 2.x driver, conversion from
driver-specific data types might not be supported.
The format of the converted data is not affected by the Windows country setting.
solidDB supports only signed, not unsigned, integer data types (SQL_TINYINT,
SQL_SMALLINT, SQL_INTEGER, SQL_BIGINT). You may bind an unsigned C
variable to a signed SQL column, but you must make sure that the values you
store fit within the range supported by both data types.
solidDB does not support the BIT/SQL_BIT data type for SQL columns. However,
you may bind a numeric SQL column to a BIT data type in your C application. For
example, you may use a TINYINT column in your database and bind that column
to a C variable of type SQL_C_BIT. The solidDB ODBC driver will try to convert
numeric types in the database to BIT data types for the C variables. The numeric
data values must be 1 or 0 or NULL; other values cause a data conversion error.
The table below does not discuss BIT/SQL_BIT data types.
CAUTION:
Although the table shows a wide range of ODBC conversions, including
conversions involving unsigned data types, solidDB supports only signed
integer data types (for example, TINYINT, SMALLINT, INTEGER, and BIGINT).
SQL_CHAR * o o o o o o o o o o o o o o o o o o o
SQL_VARCHAR * o o o o o o o o o o o o o o o o o o o
SQL_LONGVARCHAR * o o o o o o o o o o o o o o o o o o o
SQL_WCHAR o * o o o o o o o o o o o o o o o o o o
SQL_WVARCHAR o * o o o o o o o o o o o o o o o o o o
SQL_WLONGVARCHAR o * o o o o o o o o o o o o o o o o o o
SQL_TINYINT (signed) o o * o o o o o o o o o o o o o o
SQL_TINYINT (unsigned) o o o * o o o o o o o o o o o o o
SQL_SMALLINT (signed) o o o o o * o o o o o o o o o o o
SQL_SMALLINT (unsigned) o o o o o o * o o o o o o o o o o
SQL_INTEGER (signed) o o o o o o o o * o o o o o o o o
SQL_INTEGER (unsigned) o o o o o o o o o * o o o o o o o
SQL_BIGINT (signed) o o o o o o o o o o o * o o o o
SQL_BIGINT (unsigned) o o o o o o o o o o o o * o o o o
SQL_REAL o o o o o o o o o o o o o * o o o
SQL_FLOAT o o o o o o o o o o o o o o * o o
SQL_DOUBLE o o o o o o o o o o o o o o * o o
SQL_DECIMAL * o o o o o o o o o o o o o o o o
SQL_NUMERIC * o o o o o o o o o o o o o o o o
SQL_BINARY o o *
SQL_VARBINARY o o *
SQL_LONGVARBINARY o o *
SQL_TYPE_DATE o o o * o
SQL_TYPE_TIME o o o * o
SQL_TYPE_TIMESTAMP o o o o o *
* These datatypes have the word "TYPE" in the datatype name. For example,
SQL_C_TYPE_DATE, SQL_C_TYPE_TIME, and SQL_C_TYPE_TIMESTAMP.
Legend:
* Default Conversion
o Supported Conversion
Although it is not shown in the tables, the driver returns SQL_NULL_DATA in the
buffer specified by the StrLen_or_IndPtr argument when the SQL data value is
NULL. The length specified by StrLen_or_IndPtr does not include the
null-termination byte. If TargetValuePtr is a null pointer, SQLGetData returns
SQLSTATE HY009 (Invalid use of null pointer); in SQLBindCol, this unbinds the
columns.
SQL to C: Character
The following table shows the ODBC C data types to which character SQL data
can be converted. For an explanation of the columns and terms in the table, see
“Conversion Table Description (SQL to C)” on page 245.
Table 167. Character SQL Data to ODBC C Data Types
EXACT NUMERIC TYPES Data converted without Data Number of bytes of N/A
[h] truncation [b] the C data type
Truncated data 01S07
SQL_C_STINYINT Data converted with Number of bytes of
truncation of fractional digits Undefined the C data type 22003
SQL_C_UTINYINT [a]
Undefined Undefined 22018
SQL_C_TINYINT Conversion of data would
result in loss of whole (as Undefined
SQL_C_SSHORT opposed to fractional) digits
[b]
SQL_C_USHORT
Data is not a numeric-literal
SQL_C_SHORT
[b]
SQL_C_SLONG
SQL_C_ULONG
SQL_C_LONG
SQL_C_SBIGINT
SQL_C_UBIGINT
SQL_C_NUMERIC
APPROXIMATE NUMERIC Data is within the range of Data Size of the C data N/A
TYPES [h] the data type to which the type
number is being converted Undefined 2003
SQL_C_FLOAT [a] Undefined
Undefined 22018
SQL_C_DOUBLE Data is outside the range of Undefined
the data type to which the
number is being converted
[a]
[a] The value of BufferLength is ignored for this conversion. The driver assumes that the size of *TargetValuePtr is
the size of the C data type.
[f] The time fields of the timestamp structure are set to zero.
[g] The date fields of the timestamp structure are set to the current date.
[h] The exact numeric types include NUMERIC/DECIMAL as well as integer. These data types store the exact value
that you specify, as long as it is within the precision of the data type. The approximate data types include
FLOAT/REAL, which store only approximately the value that you specify (in some cases, the least significant digit
may be slightly different from what you specified).
When character SQL data is converted to numeric, date, time, or timestamp C data,
leading and trailing spaces are ignored.
SQL to C: Numeric
SQL_DECIMAL SQL_BIGINT
SQL_NUMERIC SQL_REAL
SQL_TINYINT SQL_FLOAT
SQL_SMALLINT SQL_DOUBLE
SQL_INTEGER
The following table shows the ODBC C data types to which numeric SQL data
may be converted. For an explanation of the columns and terms in the table, see
“Conversion Table Description (SQL to C)” on page 245.
Table 168. SQL Data to ODBC C Data Types
EXACT NUMERIC Data converted without Data Size of the C data N/A
TYPES [c] truncation [a] type
Truncated data 01S07
SQL_C_STINYINT Data converted with truncation Size of the C data
of fractional digits [a] Undefined type 22003
SQL_C_UTINYINT
Conversion of data would result Undefined
SQL_C_TINYINT in loss of whole (as opposed to
fractional) digits [a]
SQL_C_SBIGINT
SQL_C_UBIGINT
SQL_C_SSHORT
SQL_C_USHORT
SQL_C_SHORT a
SQL_C_SLONG
SQL_C_ULONG
SQL_C_LONG
SQL_C_NUMERIC
APPROXIMATE Data is within the range of the Data Size of the C data N/A
NUMERIC TYPES [c] data type to which the number type
is being converted [a] Undefined 22003
SQL_C_FLOAT Undefined
Data is outside the range of the
SQL_C_DOUBLE data type to which the number
is being converted [a]
[a] The value of BufferLength is ignored for this conversion. The driver assumes that the size of *TargetValuePtr is
the size of the C data type.
[c] The exact numeric types include NUMERIC/DECIMAL as well as integer. These data types store the exact value
that you specify, as long as it is within the precision of the data type. The approximate data types include
FLOAT/REAL, which store only approximately the value that you specify (in some cases, the least significant digit
may be slightly different from what you specified).
SQL to C: Binary
The following table shows the ODBC C data types to which binary SQL data may
be converted. For an explanation of the columns and terms in the table, see
“Conversion Table Description (SQL to C)” on page 245.
Table 169. Binary SQL Data to ODBC C Data Types
When binary SQL data is converted to character C data, each byte (8 bits) of source
data is represented as two ASCII characters. These characters are the ASCII
character representation of the number in its hexadecimal form. For example, a
binary 00000001 is converted to "01"and a binary 11111111 is converted to "FF".
SQL to C: Date
The following table shows the ODBC C data types to which date SQL data may be
converted. For an explanation of the columns and terms in the table, see
“Conversion Table Description (SQL to C)” on page 245.
Table 170. Date SQL Data to ODBC C Data Types
[a] The value of BufferLength is ignored for this conversion. The driver assumes that the size of *TargetValuePtr is
the size of the C data type.
[b] The time fields of the timestamp structure are set to zero.
When date SQL data is converted to character C data, the resulting string is in the
"yyyy-mm-dd"format. This format is not affected by the Windows country setting.
The following table shows the ODBC C data types to which time SQL data may be
converted. For an explanation of the columns and terms in the table, see
“Conversion Table Description (SQL to C)” on page 245.
Table 171. Time SQL Data to ODBC C Data Types
[b]: The value of BufferLength is ignored for this conversion. The driver assumes that the size of *TargetValuePtr is
the size of the C data type.
[c]: The date fields of the timestamp structure are set to the current date and the fractional seconds field of the
timestamp structure is set to zero.
When time SQL data is converted to character C data, the resulting string is in the
"hh:mm:ss "format.
SQL to C: Timestamp
[a] The value of BufferLength is ignored for this conversion. The driver assumes that the size of *TargetValuePtr is
the size of the C data type.
When timestamp SQL data is converted to character C data, the resulting string is
in the "yyyy-mm-dd hh:mm:ss [ .f ...]"format, where up to nine digits may be used
for fractional seconds. The format is not affected by the Windows country setting.
(Except for the decimal point and fractional seconds, the entire format must be
used, regardless of the precision of the timestamp SQL data type.)
[b] The numbers in this list are the numbers stored in the fields of the
TIMESTAMP_STRUCT structure.
The following table shows the supported conversions from ODBC C data types to
ODBC SQL data types. A solid circle indicates the default conversion for an SQL
data type (the C data type from which the data will be converted when the value
of ValueType or the SQL_DESC_CONCISE_TYPE descriptor field is
SQL_C_DEFAULT). A hollow circle indicates a supported conversion.
The format of the converted data is not affected by the Windows country setting.
solidDB supports only signed, not unsigned, integer data types (SQL_TINYINT,
SQL_SMALLINT, SQL_INTEGER, SQL_BIGINT). You may bind an unsigned C
variable to a signed SQL column, but you must make sure that the values you
store fit within the range supported by both data types.
solidDB does not support the BIT/SQL_BIT data type for SQL columns. However,
you may bind a numeric SQL column to a BIT data type in your C application. For
CAUTION:
Although the table above shows a wide range of ODBC conversions, including
conversions involving unsigned data types, solidDB supports only signed
integer data types (for example, TINYINT, SMALLINT, INT, and BIGINT).
Table 174. SQL Data Type — SQL_datatype where Datatype Is:
T S I
I M N B
T N S A I T I
I Y M L N E B G
N I A L T G I I L
W Y N L I E E G N O
L L I T L N G R I T N
O O N ( I T E ( N ( G
N N T u N (u R u T u V V T
G W G ( n T n ( n ( n A A I
V V V V D N s s (s s s s s s R R M
A A A A E U i i i i i i i i D B B B E
R R W R R C M g g g g g g g g F O I I I S
C C C C C C I E n n n n n n n n R L U N N N D T T
H H H H H H M R e e e e e e e e E O B A A A A I A
A A A A A A A I d d d d d d d d A A L R R R T M M
C Data Type R R R R R R L C ) ) ) ) ) ) ) ) L T E Y Y Y E E P
SQL_C_CHAR * * * o o o * * o o o o o o o o o o o o o o o o o
SQL_WCHAR o o o * * * o o o o o o o o o o o o o o o o o o o
SQL_C_NUMERIC * o o o o o o o o o o o o o o o o o o
SQL_C_STINYINT o o o o o o o o * o o o o o o o o o o
SQL_C_UTINYINT o o o o o o o o o * o o o o o o o o o
SQL_C_TINYINT o o o o o o o o o o o o o o o o o o o
SQL_C_SSHORT o o o o o o o o o o * o o o o o o o o
SQL_C_USHORT o o o o o o o o o o o * o o o o o o o
SQL_C_SHORT o o o o o o o o o o o o o o o o o o o
SQL_C_SLONG o o o o o o o o o o o o * o o o o o o
SQL_C_ULONG o o o o o o o o o o o o o * o o o o o
SQL_C_LONG o o o o o o o o o o o o o o o o o o o
SQL_C_SBIGINT o o o o o o o o o o o o o o * * o o o
SQL_C_UBIGINT o o o o o o o o o o o o o o o * o o o
SQL_C_FLOAT o o o o o o o o o o o o o o o o * o o
SQL_C_DOUBLE o o o o o o o o o o o o o o o o o * *
SQL_C_BINARY o o o o o o o o o o o o o o o o o o o * * * o o o
SQL_C_DATE o o o o o o * o
SQL_C_TIME o o o o o o * o
SQL_C_TIMESTAMP o o o o o o o o *
Legend:
* Default conversion,
o Supported conversion
C to SQL: Character
SQL_C_CHAR SQL_C_WCHAR
The following table shows the ODBC SQL data types to which C character data
may be converted. For an explanation of the columns and terms in the table, see
“Conversion Table Description (C to SQL)” on page 258.
Note: The length of the Unicode data type must be an even number when
character C data is converted to Unicode SQL data.
Table 175. C Character Data to ODBC SQL Data Types
[d] The date portion of the timestamp is set to the current date.
[e] The driver/data source effectively waits until the entire string has been received (even if the character data is
sent in pieces by calls to SQLPutData) before attempting to perform the conversion.
When character C data is converted to numeric, date, time, or timestamp SQL data,
leading and trailing blanks are ignored.
When character C data is converted to binary SQL data, each two bytes of
character data are converted to a single byte (8 bits) of binary data. Each two bytes
of character data represent a number in hexadecimal form. For example, "01" is
converted to a binary 00000001 and "FF" is converted to a binary 11111111.
The driver always converts pairs of hexadecimal digits to individual bytes and
ignores the null termination byte. Because of this, if the length of the character
string is odd, the last byte of the string (excluding the null termination byte, if any)
is not converted.
Note: Because binding character C data to a binary SQL data type is inefficient
and slow, refrain from doing this.
C to SQL: Numeric
SQL_INTEGER [a]
SQL_BIGINT [a]
[a] For the "n/a" case, a driver may optionally return SQL_SUCCESS_WITH_INFO and
01S07 when there is a fractional truncation.
The driver ignores the length or indicator value when converting data from the
numeric C data types and assumes that the size of the data buffer is the size of the
numeric C data type. The length or indicator value is passed in the
StrLen_or_IndPtr argument in SQLPutData and in the buffer specified with the
StrLen_or_IndPtr argument in SQLBindParameter. The data buffer is specified with
the DataPtr argument in SQLPutData and the ParameterValuePtr argument in
SQLBindParameter.
C to SQL: Bit
SQL_VARCHAR
SQL_LONGVARCHAR
SQL_WCHAR
SQL_WVARCHAR
SQL_WLONGVARCHAR
SQL_NUMERIC
SQL_TINYINT
SQL_SMALLINT
SQL_INTEGER
SQL_BIGINT
SQL_REAL
SQL_FLOAT
SQL_DOUBLE
The driver ignores the length or indicator value when converting data from the bit
C data types and assumes that the size of the data buffer is the size of the bit C
data type. The length or indicator value is passed in the StrLen_or_Ind argument
in SQLPutData and in the buffer specified with the StrLen_or_IndPtr argument in
SQLBindParameter. The data buffer is specified with the DataPtr argument in
SQLPutData and the ParameterValuePtr argument in SQLBindParameter.
C to SQL: Binary
SQL_C_BINARY
The following table shows the ODBC SQL data types to which binary C data may
be converted. For an explanation of the columns and terms in the table, see
“Conversion Table Description (C to SQL)” on page 258.
SQL_SMALLINT
SQL_INTEGER
SQL_BIGINT
SQL_REAL
SQL_FLOAT
SQL_DOUBLE
SQL_TYPE_DATE
SQL_TYPE_TIME
SQL_TYPE_TIMESTAMP
C to SQL: Date
The following table shows the ODBC SQL data types to which date C data may be
converted. For an explanation of the columns and terms in the table, see
“Conversion Table Description (C to SQL)” on page 258.
When date C data is converted to character SQL data, the resulting character data
is in the "yyyy-mm-dd "format.
The driver ignores the length or indicator value when converting data from the
date C data types and assumes that the size of the data buffer is the size of the
date C data type. The length or indicator value is passed in the StrLen_or_Ind
argument in SQLPutData and in the buffer specified with the StrLen_or_IndPtr
argument in SQLBindParameter. The data buffer is specified with the DataPtr
argument in SQLPutData and the ParameterValuePtr argument in
SQLBindParameter.
C to SQL: Time
SQL_C_TIME
T he following table shows the ODBC SQL data types to which time C data may
be converted. For an explanation of the columns and terms in the table, see
“Conversion Table Description (C to SQL)” on page 258.
When time C data is converted to character SQL data, the resulting character data
is in the "hh:mm:ss" format.
The driver ignores the length or indicator value when converting data from the
time C data types and assumes that the size of the data buffer is the size of the
time C data type. The length or indicator value is passed in the StrLen_or_Ind
argument in SQLPutData and in the buffer specified with the StrLen_or_IndPtr
argument in SQLBindParameter. The data buffer is specified with the DataPtr
argument in SQLPutData and the ParameterValuePtr argument in
SQLBindParameter.
C to SQL: Timestamp
SQL_C_TIMESTAMP
The following table shows the ODBC SQL data types to which timestamp C data
may be converted. For an explanation of the columns and terms in the table, see
“Conversion Table Description (C to SQL)” on page 258.
When timestamp C data is converted to character SQL data, the resulting character
data is in the "yyyy-mm-dd hh:mm:ss [ .f. ..]" format.
Column
C Data Type C Data Value SQL Data Type Length SQL Data Value SQLSTATE
Column
C Data Type C Data Value SQL Data Type Length SQL Data Value SQLSTATE
Note:
[a] "\0" represents a null-termination byte. The null-termination byte is required only if the length of the data is
SQL_NTS.
[b] In addition to bytes for numbers, one byte is required for a sign and another byte is required for the decimal
point.
[c] The numbers in this list are the numbers stored in the fields of the SQL_DATE_STRUCT structure.
[d] The numbers in this list are the numbers stored in the fields of the SQL_TIMESTAMP_STRUCT structure.
A scalar function is a function that returns one value for each row in the query.
Functions like SQRT() and ABS() are scalar functions. Functions like SUM() and
AVG() are not scalar functions because they return a single value even if they
process more than one row.
This section includes tables for each scalar function category. Within each table,
functions have been added in ODBC 3.0 to align with SQL-92. Each table also
provides the version number when the function was introduced.
Because functions are often data-source-specific, ODBC does not require a data
type for return values from scalar functions. To force data type conversion,
applications should use the CONVERT scalar function.
Note:
ODBC and SQL-92 classify functions in different ways. ODBC classifies scalar
functions by argument type, whereas SQL-92 classifies them by return value. For
example, in ODBC, the EXTRACT function is classified as a timedate function
because the extract-field argument is a timedate keyword and the extract_source
argument is a timedate or interval expression. In SQL-92, however, the EXTRACT
function is classified as a numeric scalar function because the return value is
numeric.
String functions
This topic lists string manipulation functions.
271
Applications can call SQLGetInfo with the SQL_STRING_FUNCTIONS information
type to determine which string functions are supported by a driver.
start, length or count These arguments can be a numeric literal or the result of
another scalar function, where the underlying data type can
be represented as SQL_TINYINT, SQL_SMALLINT, or
SQL_INTEGER
The following string functions are 1-based, that is, the first character in the string is
character 1, not character 0.
Function Description
(ODBC 3.0)
CHAR(code) Returns the character that has the ASCII code value
specified by code. The value of code should be
(ODBC 1.0) between 0 and 255; otherwise, the return value is
data source-dependent.
Function Description
Function Description
(ODBC 1.0)
Function Description
Numeric functions
This topic describes numeric functions that are included in the ODBC scalar
function set.
Except for ABS, ROUND, TRUNCATE, SIGN, FLOOR, and CEILING (which return
values of the same data type as the input parameters), all numeric functions return
values of data type SQL_FLOAT.
Function Description
(ODBC 1.0)
Function Description
(ODBC 1.0)
(ODBC 1.0)
(ODBC 2.0)
(ODBC 1.0)
(ODBC 1.0)
(ODBC 1.0)
Function Description
Function Description
Function Description
(ODBC 1.0)
DAYOFWEEK(date_exp) Returns the day of the week based on the week field in
date_exp as an integer value in the range of 1-7, where 1
(ODBC 1.0) represents Sunday.
DAYOFYEAR(date_exp) Returns the day of the year based on the year field in
date_exp as an integer value in the range of 1-366.
(ODBC 1.0)
Function Description
NOW [(timestamp_precision)] Returns current date and time as a timestamp value. The
timestamp_precision argument (0-6) determines the
(ODBC 1.0) milliseconds precision of the returned timestamp.
Function Description
Function Description
WEEK(date_exp) Returns the week of the year based on the week field in
date_exp as an integer value in the range of 1-53.
(ODBC 1.0)
Function Description
IFNULL(exp, value) If exp is null, value is returned. If exp is not null, exp is
returned. The possible data type(s) of value must be
(ODBC 1.0) compatible with the data type of exp
The ODBC syntax for the explicit data type conversion function does not restrict
conversions. The validity of specific conversions of one data type to another data
type is dependent on each driver-specific implementation. The driver, as it
translates the ODBC syntax into the native syntax, reject those conversions that,
although legal in the ODBC syntax, are not supported by the data source.
Applications can call the ODBC function SQLGetInfo to inquire about conversions
supported by the data source.
CONVERT(value_exp, data_type)
The function returns the value specified by value_exp converted to the specified
data_type, where data_type is one of the following keywords:
v SQL_BIGINT
v SQL_SMALLINT
v SQL_BINARY
v SQL_DATE
v SQL_CHAR
v SQL_TIME
v SQL_DECIMAL
v SQL_TIMESTAMP
v SQL_DOUBLE
v SQL_TINYINT
v SQL_FLOAT
v SQL_VARBINARY
v SQL_INTEGER
v SQL_VARCHAR
v SQL_LONGVARBINARY
v SQL_WCHAR
v SQL_LONGVARCHAR
v SQL_WLONGVARCHAR
v SQL_NUMERIC
v SQL_WVARCHAR
v SQL_REAL
The ODBC syntax for the explicit data type conversion function does not support
specification of conversion format. If specification of explicit formats is supported
by the underlying data source, a driver must specify a default value or implement
format specification.
The argument value_exp can be a column name, the result of another scalar
function, or a numeric or string literal. The following example converts the output
of the CURDATE scalar function to a character string:
{ fn CONVERT( { fn CURDATE() }, SQL_CHAR) }
The following two examples illustrate the use of the CONVERT function. These
examples assume the existence of a table called EMPLOYEES, with an EMPNO
column of type SQL_SMALLINT and an EMPNAME column of type SQL_CHAR.
Support for the CAST function is at the FIPS Transitional level. For details on data
type conversion in the CAST function, see the SQL-92 specification.
To determine application support for the CAST function, call SQLGetInfo with the
SQL_SQL_CONFORMANCE information type. The CAST function is supported if
the return value for the information type is:
v SQL_SC_FIPS127_2_TRANSITIONAL
v SQL_SC_SQL92_INTERMEDIATE
v SQL_SC_SQL92_FULL
Timeouts have factory default values and they can usually be set with different .ini
parameters. Some startup defaults can be dynamically changed with different
controls, by using SQL, or by using the driver interfaces and connection string
parameters.
Client timeouts
Timeouts related to the database client are introduced in this topic.
Login timeout
This timeout refers to the number of seconds the driver waits for the login
(SQLConnect) to succeed. The default value is driver-dependent. If the value (or
ValuePtr in ODBC) is 0, the timeout is disabled and a connection attempt will wait
indefinitely. If the specified timeout exceeds the maximum login timeout in the
data source, the driver substitutes that value and returns SQLSTATE 01S02 (Option
value changed).
Overridden Connection
INI parameter with SQL Driver string
Client-side: ODBC: -c
[Com] milliseconds
ConnectTimeout=milliseconds SQL_ATTR_LOGIN_TIMEOUT (in
seconds)
or:
SQL_ATTR_LOGIN_TIMEOUT_MS (in
[Link] parameter with option milliseconds, non-standard)
-cmilliseconds
JDBC:
For example:
Method (JDBC 2.0)
[Com]
Connect=tcp -c1000 1315 [Link](seconds);
"solid_login_timeout_ms" (milliseconds)
ODBC:
287
Connection timeout
This timeout refers to the number of seconds (or milliseconds) the driver waits for
any request on the connection to complete. This timeout is not associated with the
query execution or login. Upon timeout, the driver disconnects from the solidDB
server.
If the client can detect reliably that the server is not reachable, it does not wait for
the timeout to expire. This can happen, for example, if the server is expected to
run on the same host, and the client detects that the server is not running.
The driver returns SQLSTATE HYT00 (Timeout expired) if it is possible to time out
in a situation not associated with query execution or login. If the value (or
ValuePtr in ODBC) is 0 (the default value), there is no timeout.
This timeout applies to all ODBC functions (ODBC 3.5 specifications) except the
following:
SQLDrivers
SQLDataSources
SQLGetEnvAttr
SQLSetEnvAttr
Overridden Connection
INI parameter with SQL Driver string
Client-side: ODBC:
-r milliseconds
[Com]
ClientReadTimeout=milliseconds SQL_ATTR_CONNECTION_TIMEOUT (in
seconds)
or:
SQL_ATTR_CONNECTION_TIMEOUT_MS
[Link] parameter with option (in milliseconds, non-standard)
-rmilliseconds
JDBC:
For example:
Non-standard connection property:
[Com]
Connect=tcp -r1000 1315 "solid_connection_timeout_ms" (milliseconds)
or method:
[Link]()
(milliseconds)
ODBC:
See also:
SOLID Server Error 14518:
Connection to the server is broken, connection lost.
Query timeout
This timeout refers to the number of seconds the driver waits for an SQL statement
to execute. If the value (or ValuePtr in ODBC) is 0 (the default value), there is no
timeout.
If the specified timeout exceeds the maximum timeout in the data source, or if the
specified timeout is smaller than the minimum timeout, SQLSetStmtAttr substitutes
that value and returns SQLSTATE 01S02 (Option value changed).
This timeout applies to the ODBC functions (ODBC 3.5 specifications) as follows:
SQLBrowseConnect
SQLBulkOperations
SQLColumnPrivileges
SQLColumns
SQLConnect
SQLDriverConnect
SQLExecDirect
SQLExecute
SQLExtendedFetch
SQLForeignKeys
SQLGetTypeInfo
SQLParamData
SQLPrepare
SQLPrimaryKeys
SQLProcedureColumns
SQLProcedures
SQLSetPos
SQLSpecialColumns
SQLStatistics
SQLTablePrivileges
Note: The application need not call SQLCloseCursor to reuse the statement if a
SELECT statement timed out. The query timeout set in this statement attribute is
valid in both synchronous and asynchronous modes.
Table 193. Query Timeout
INI Overridden
parameter with SQL Driver Connection string
ODBC:
SQL_ATTR_QUERY_TIMEOUT (in
seconds)
SQL_ATTR_QUERY_TIMEOUT_MS (in
milliseconds, non-standard)
ODBC:
Server timeouts
Timeouts related to the database server are introduced in this topic.
The server can control the amount of time spent on the execution of one SQL
statement. When the time expires, the server terminates the statements and returns
a corresponding error code. This timeout applies to the following calls (ODBC 3.5
specifications):
v SQLExecute()
v SQLExecDirect()
v SQLPrepare()
v SQLForeignKeys()
v SQLColumns()
v SQLProcedureColumns()
v SQLSpecialColumns()
v SQLStatistics()
v SQLPrimaryKeys()
v SQLProcedures()
v SQLTables()
v SQLTablePrivileges()
v SQLColumnPrivileges()
v SQLGetTypeInfo()
INI Connection
parameter Overridden with SQL Driver string
SQL_ATTR_QUERY_TIMEOUT_MS
(in milliseconds, non-standard)
JDBC:
[Link]()
Note:
v In versions prior to V6.5 Fix Pack
12, the timeout unit in SMA
connections is milliseconds.
v As of V6.5 Fix Pack 12, the
timeout unit in SMA connections
is seconds.
See also:
SOLID Server Error 14518:
Connection to the server is broken, connection lost.
The lock wait timeout specifies the time in seconds (or milliseconds) that the engine
waits for a lock to be released. When the timeout interval is reached, solidDB
terminates the timed-out transaction. The default value is 30 seconds.
Lock wait timeout is used in deadlock resolution. In that case, the oldest
transaction participating in a deadlock is aborted.
Table 195. Lock wait timeout
Connection
INI parameter Overridden with SQL Driver string
[General]
LockWaitTimeOut=seconds SET LOCK TIMEOUT
{seconds | milliseconds MS}
The optimistic lock timeout specifies the time in seconds (or milliseconds) for
optimistic lock timeout. Optimistic lock is an additional lock that can be enacted in
order to ensure that SELECT FOR UPDATE will always lead to successful updates
in the optimistic concurrency mode. The default is zero; no optimistic lock is used,
and a transaction may be aborted after each statement as a result of early
transaction validation. When the timeout is set to a non-zero value, SELECT FOR
UPDATE will wait until the lock is obtained, or it is timed-out and aborted. When
set, the timeout affects also all DELETE and UPDATE statements.
Table 196. Optimistic lock wait timeout
INI
parameter Overridden with SQL Driver Connection string
Occasionally, the transaction will acquire an exclusive lock to a table. This may be
result of a lock escalation, an attempt to execute the ALTER TABLE statement, or
as a side effect of some advanced replication commands. If there is a table-level
conflict, this setting provides the transaction's wait period until the exclusive or
shared lock is released. The unit is seconds, the default value is 30 seconds, and
the parameter access mode is read/write.
To be more specific, table level locks are used when the PESSIMISTIC keyword is
explicitly provided in the following commands:
IMPORT SUBSCRIPTIONMESSAGE message_name EXECUTE
(only with NO EXECUTE option)
MESSAGE message_name FORWARD
MESSAGE message_name GET REPLY
DROP SUBSCRIPTION.
Overridden with
INI parameter SQL Driver Connection string
[General]
TableLockWaitTimeout=seconds
The transaction idle timeout specifies the time in minutes after an idle transaction is
aborted; a negative or zero value means infinite. The default value is 120 minutes.
Overridden with
INI parameter SQL Driver Connection string
[Srv]
AbortTimeOut
The connection idle timeout specifies the continuous idle time in minutes (or
seconds/milliseconds in a statement) after which a connection is dropped (by the
server); negative or zero value indicates an infinite value. The default value is 480
minutes.
Table 199. connection idle timeout
Connection
INI parameter Overridden with SQL Driver string
[Srv]
ConnectTimeOut=minutes SET IDLE TIMEOUT JDBC:
{seconds | milliseconds MS}
Connection property
(non-standard):
"solid_idle_timeout_min"
If the SET IDLE TIMEOUT has been set and the transaction is idle for the given
period, the error below is given:
SOLID Database Error 10026:
Transaction is timed out
HotStandby timeouts
Timeouts related to the HotStandby server are introduced in this topic.
Connect timeout
Overridden with
INI parameter SQL Driver Connection string
[HotStandby]
ConnectTimeout=milliseconds
Ping timeout
Overridden with
INI parameter SQL Driver Connection string
[HotStandby]
PingTimeout=milliseconds
JDBC:
solid_tf1_reconnect_timeout
[TransparentFailover] ODBC:
WaitTimeout=milliseconds
SQL_ATTR_TF_WAIT_TIMEOUT
JDBC:
solid_tf_wait_timeout
Generally, the factory value settings offer the best performance and operability, but
in some special cases modifying a parameter will improve performance. You can
change the parameters by editing the [Link] configuration file.
The parameter values set in the client side configuration file come to effect each
time an application issues a call to the SqlConnect ODBC function. If the values are
changed in the file during the program's run time, they affect the connections
established thereafter.
When solidDB is started, it attempts to open the configuration file [Link]. If the
file does not exist, solidDB uses the factory values for the parameters. If the file
exists, but a value for a particular parameter is not set, solidDB will use a factory
value for that parameter. The factory values may depend on the operating system
you are using.
By default, the client looks for the [Link] file in the current working directory,
which is normally the directory from which you started the client. When searching
for the file, solidDB uses the following precedence (from high to low):
v location specified by the SOLIDDIR environment variable (if this environment
variable is set)
v current working directory
When you format the client-side [Link] file, the same rules apply as for the
server-side [Link] file. For more information, refer to section Rules for
formatting the [Link] file in IBM solidDB Administrator Guide.
[Client]
;at SQLConnect, timeout after this time (ms)
ConnectTimeout = 5000
;at any ODBC network request, timeout after this time (ms)
ClientReadTimeout = 10000
[Data Sources]
Primary_Server = tcp irix1 1315, The Primary Server
Secondary_Server = tcp irix2 1315, The Secondary Server
295
Client section
Table 203. Client parameters
Communication section
Table 204. Communication parameters
This value is used also when the SQLConnect() call is issued with an
empty data source name.
The client-side [Link] parameter defines the login timeout in
ConnectTimeout milliseconds. OS-specific
The value of the parameter can be overridden with the connect string
option -c or the ODBC attribute SQL_ATTR_LOGIN_TIMEOUT.
Note: This parameter applies for the TCP protocol only.
This parameter controls the TCP socket linger (SO_LINGER) behavior no
SocketLinger after a close on the socket connection is issued. It indicates if the system
attempts to deliver any buffered data (yes), or if the system discards it
(no), when a close() is issued.
This parameter defines the length of the time interval (in seconds) the
SocketLingerTime socket lingers after a close is issued. If the time interval expires before the 0
graceful shutdown sequence completes, an abortive shutdown sequence
occurs (the data is discarded). The default value zero indicates that the
system default is used (typically, 1 second)
Trace If this parameter is set to yes, trace information about network messages no
for the established network connection is written to a file specified with
the TraceFile parameter.
TraceFile If the Trace parameter is set to yes, trace information about network [Link]
messages is written to a file specified with this TraceFile parameter. (written to the
current working
directory of the
server or client
depending on which
end the tracing is
started)
logical name = network name, These parameters can be used to give a logical name to a N/A
Description solidDB server in a [Link] file of the client
application.
SharedMemoryAccess section
Table 206. Shared memory access parameters (client-side)
[SharedMemoryAccess] Description Factory value Startup
SignalHandler The SignalHandler parameter controls the SMA signal yes NA
handler functionality.
The SMA driver signal handler installs itself when the first
SMA connection is established and uninstalls itself when
the last SMA connection is closed. Previously installed
signal handlers are retained.
The signals are defined as integers or with the following Windows: SIGINT
mnemonics: SIGSTOP, SIGKILL, SIGINT, SIGTERM,
SIGQUIT, SIGABORT.
Note: If the SMA application loops outside of the SMA
driver (for example, does not call any functions), the
signal can fail to terminate the application. In such a case:
1. Throw out the connections at the server.
admin command ’throwout <userid>’
2. Use SIGKILL signal to force the SMA application to
exit.
kill -SIGKILL <pid>
TransparentFailover section
Table 207. TransparentFailover parameters
[TransparentFailover] Description Factory value
ReconnectTimeout This parameter specifies how long (in milliseconds) the driver 10000
should wait until it tries to reconnect to the primary in case of
TF switchover or failover. If the driver cannot find the new
primary (reconnect), an error is returned and the TF connection
becomes broken.
WaitTimeout This parameter specifies how long (in milliseconds) the driver 10000
should wait for the server to switch state. When the driver tries
to reconnect to the servers, it might connect to the server being
in an intermediate (switching or uncertain) state.
301
cursors (continued) functions (continued)
types supported 33 CURRENT_TIMESTAMP 279
using 31 CURRENTTIME 278
CURTIME (function) 279 CURTIME 279
DATABASE 283
DAYNAME 279
D DAYOFMONTH 279
DAYOFWEEK 279
Data Sources
DAYOFYEAR 279
configuring for Windows 20
DEGREES 276
connecting to 15
DIFFERENCE 273
defining in [Link] 18
executing asynchronously 26
empty data source name 19
EXP 277
retrieving catalog information 26
EXTRACT 279
data types 225
FLOOR 277
explicit conversion 284
guidelines for calling 14
DATABASE (function) 283
HOUR 280
DatabaseMetaData interface
IFNULL 283
methods 56
INSERT 273
DAYNAME (function) 279
LCASE 273
DAYOFMONTH (function) 279
LEFT 273
DAYOFWEEK (function) 279
LENGTH 273
DAYOFYEAR (function) 279
LOCATE 274
debugging
LOG 277
applications 49
LOG10 277
DEGREES (function) 276
LTRIM 274
DIFFERENCE (function) 273
MINUTE 280
driver interface (JDBC) 56
MOD 277
dynamic libraries 9
MONTH 280
MONTHNAME 280
NOW 280
E OCTET_LENGTH 274
END LOOP 219 PI 277
errors POSITION 274
JDBC Driver 54 POWER 277
processing messages 40 prototypes 14
SA functions 95 QUARTER 280
sample messages 38 RADIANS 277
ExecRowsPerMessage (parameter) 296 REPEAT 274
EXP (function) 277 REPLACE 274
EXTRACT (function) 279 return codes 15
RIGHT 274
ROUND 277
F RTRIM 275
scalar 14
FLOOR (function) 277
Scalar 271
fn
SECOND 280
usage in {fn func_name} 14, 281
SIGN 277
forward cursor 33
SIN 277
functions
SOUNDEX 275
ABS 276
SPACE 275
ACOS 276
SQLAllocConnect 177
additional extensions to SQL 29
SQLAllocEnv 177
ASCII 272
SQLAllocHandle 177
ASIN 276
SQLAllocStmt 179
ATAN 276
SQLBindCol 181
ATAN2 276
SQLBindParameter 179
BIT_LENGTH 272
SQLBrowseConnect 177
CAST 285
SQLBulkOperations 182
CEILING 276
SQLCancel 184
CHAR 272
SQLCloseCursor 184
CHAR_LENGTH 272
SQLColAttribute 181
CHARACTER_LENGTH 273
SQLColAttributes 181
CONCAT 273
SQLColumnPrivileges 183
CONVERT 284
SQLColumns 183
COS 276
SQLConnect 177
COT 276
SQLCopyDesc 179
CURDATE 279
Index 303
LOGIN_CATALOG() scalar function
LOOP 219
15
R
LTRIM (function) 274 RADIANS (function) 277
Ref interface
methods 56
REPEAT (function) 274
M REPLACE (function) 274
MaxSpace (parameter) 171 ResultSet interface
MINUTE (function) 280 methods 56
MOD (function) 277 ResultSetMetaData interface
MONTH (function) 280 methods 56
MONTHNAME (function) 280 return code
for functions 15
RIGHT (function) 274
N ROUND (function) 277
native scalar functions 14 rowset 32
network names 16 RowsPerMessage (parameter) 296
NoAssertMessages (parameter) 296 RTRIM (function) 275
non-standard behavior
ODBC 6
NOW (function) 280 S
numeric functions SA
ODBC 275 sample program 94
SaErrorInfo
solidDB SA 95
O scalar functions 14
octet length 240 native 14
OCTET_LENGTH (function) 274 ODBC 271
ODBC SQL-92 271
additional functions to SQL 29 scrollable cursors 33
Driver 14 SECOND (function) 280
extensions 26 server timeouts 290
function support 177 SET LOGREADER BATCH (statement) 176
non-standard behavior 6 SIGN (function) 277
solidDB extensions for ODBC API 29 SIN (function) 277
ODBC handles 23 SocketLinger (parameter) 297
ODBCCharBinding (parameter) 296 SocketLingerTime (parameter) 297
ODBCHandleValidation (parameter) 296 [Link] 295
optimistic lock timeout 292 configuration parameters 295
optimizer hints 28 [Link] 77
solidDB Data Dictionary
Unicode 163
solidDB Export
P Unicode 163
parameters solidDB JDBC Driver
client-side 295 classes and methods 56
PI (function) 277 connection to the database 54
Ping Timeout 293 conversion matrix 90
PooledConnection API Functions DatabaseMetaData interface 56
addConnectionEventListener 68 description 6, 51
close 68 Driver class 56
getConnection 68 getting started 51
removeConnectionEventListener 68 PreparedStatement interface 56
POSITION (function) 274 Ref interface 56
POWER (function) 277 registering 53
PreparedStatement interface ResultSet interface 56
methods 56 ResultSetMetaData interface 56
procedures SQLData interface 56
calling in ODBC 27 SQLInput interface 56
SQLOutput interface 56
Statement interface 56
Q Struct interface 56
QUARTER (function) 280 Unicode 166
query timeout 289 solidDB ODBC API
Unicode 166
solidDB ODBC Driver
description 12
Index 305
static library 9 UTF-8
static SQL description 160
code example 41
stored procedures
JDBC Driver 56
string functions
V
Variables
ODBC 272
Unicode 166
struct interface
solidDB JDBC Driver 56
SUBSTRING (function) 275
W
WebSphere
T compatibility 63
WEEK (function) 282
table lock wait timeout 292
TAN (function) 277
TC Info 16
testing Y
applications 49 YEAR (function) 282
Timeout controls 287
TIMESTAMPADD (function) 281
TIMESTAMPDIFF (function) 282
Trace (parameter) 297
TraceFile (parameter) 298
transaction idle timeout 292
transactions
autocommit mode 24
committing read-only 24
JDBC Driver 54
terminating 40
Transfer Octet Length 240
translation
effect on Unicode columns 166
TRIM (function) 275
TRUNCATE (function) 278
U
UCASE (function) 275
Unicode
character translation 166
compliance 159
converting 164
creating columns for storing data 161
description 159
encoding forms 160
loading data 161, 163
setting up 161, 166
solidDB Data Dictionary 163
solidDB Export 163
solidDB JDBC Driver 166
solidDB ODBC API 166
solidDB ODBC Driver 166
solidDB Remote Control 163
solidDB SQL Editor 163
Speed Loader 163
standard 160
string functions 166
user names and passwords 161
using in database entity names 161
variables and binding 166
unixODBC 20
UseEncryption (parameter) 297
USER (function) 283
UTF-16
description 160
No portion of this product may be used in any way except as expressly authorized
in writing by IBM.
This information was developed for products and services offered in the U.S.A.
IBM may not offer the products, services, or features discussed in this document in
other countries. Consult your local IBM representative for information on the
products and services currently available in your area. Any reference to an IBM
product, program, or service is not intended to state or imply that only that IBM
product, program, or service may be used. Any functionally equivalent product,
program, or service that does not infringe any IBM intellectual property right may
be used instead. However, it is the user's responsibility to evaluate and verify the
operation of any non-IBM product, program, or service.
IBM may have patents or pending patent applications covering subject matter
described in this document. The furnishing of this document does not grant you
any license to these patents. You can send license inquiries, in writing, to:
For license inquiries regarding double-byte (DBCS) information, contact the IBM
Intellectual Property Department in your country or send inquiries, in writing, to:
The following paragraph does not apply to the United Kingdom or any other
country where such provisions are inconsistent with local law: INTERNATIONAL
BUSINESS MACHINES CORPORATION PROVIDES THIS PUBLICATION "AS IS"
WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR
PURPOSE. Some states do not allow disclaimer of express or implied warranties in
certain transactions, therefore, this statement may not apply to you.
307
This information could include technical inaccuracies or typographical errors.
Changes are periodically made to the information herein; these changes will be
incorporated in new editions of the publication. IBM may make improvements
and/or changes in the product(s) and/or the program(s) described in this
publication at any time without notice.
Any references in this information to non-IBM Web sites are provided for
convenience only and do not in any manner serve as an endorsement of those Web
sites. The materials at those Web sites are not part of the materials for this IBM
product and use of those Web sites is at your own risk.
IBM may use or distribute any of the information you supply in any way it
believes appropriate without incurring any obligation to you.
Licensees of this program who wish to have information about it for the purpose
of enabling: (i) the exchange of information between independently created
programs and other programs (including this one) and (ii) the mutual use of the
information which has been exchanged, should contact:
The licensed program described in this document and all licensed material
available for it are provided by IBM under terms of the IBM Customer Agreement,
IBM International Program License Agreement or any equivalent agreement
between us.
All statements regarding IBM's future direction or intent are subject to change or
withdrawal without notice, and represent goals and objectives only.
This information contains examples of data and reports used in daily business
operations. To illustrate them as completely as possible, the examples include the
COPYRIGHT LICENSE:
Each copy or any portion of these sample programs or any derivative work, must
include a copyright notice as follows:
© your company name) (year). Portions of this code are derived from IBM Corp.
Sample Programs.
© Copyright IBM Corp. _enter the year or years_. All rights reserved.
If you are viewing this information softcopy, the photographs and color
illustrations may not appear.
Trademarks
IBM, the IBM logo, [Link]®, Solid, solidDB, InfoSphere, DB2®, Informix®, and
WebSphere are trademarks or registered trademarks of International Business
Machines Corp., registered in many jurisdictions worldwide. Other product and
service names might be trademarks of IBM or other companies. A current list of
IBM trademarks is available on the Web at “Copyright and trademark information”
at [Link]/legal/[Link].
Java and all Java-based trademarks and logos are trademarks or registered
trademarks of Oracle and/or its affiliates.
UNIX is a registered trademark of The Open Group in the United States and other
countries.
Other product and service names might be trademarks of IBM or other companies.
Notices 309
310 IBM solidDB: Programmer Guide
Printed in USA
SC23-9870-06