1 /**
  2  * Define CUBRID Function codes constants
  3  */
  4 exports.CASFunctionCode = {
  5   CAS_FC_END_TRAN            : 1,
  6   CAS_FC_PREPARE             : 2,
  7   CAS_FC_EXECUTE             : 3,
  8   CAS_FC_GET_DB_PARAMETER    : 4,
  9   CAS_FC_SET_DB_PARAMETER    : 5,
 10   CAS_FC_CLOSE_REQ_HANDLE    : 6,
 11   CAS_FC_CURSOR              : 7,
 12   CAS_FC_FETCH               : 8,
 13   CAS_FC_SCHEMA_INFO         : 9,
 14   CAS_FC_OID_GET             : 10,
 15   CAS_FC_OID_PUT             : 11,
 16   CAS_FC_DEPRECATED1         : 12,
 17   CAS_FC_DEPRECATED2         : 13,
 18   CAS_FC_DEPRECATED3         : 14,
 19   CAS_FC_GET_DB_VERSION      : 15,
 20   CAS_FC_GET_CLASS_NUM_OBJS  : 16,
 21   CAS_FC_OID_CMD             : 17,
 22   CAS_FC_COLLECTION          : 18,
 23   CAS_FC_NEXT_RESULT         : 19,
 24   CAS_FC_EXECUTE_BATCH       : 20,
 25   CAS_FC_EXECUTE_ARRAY       : 21,
 26   CAS_FC_CURSOR_UPDATE       : 22,
 27   CAS_FC_GET_ATTR_TYPE_STR   : 23,
 28   CAS_FC_GET_QUERY_INFO      : 24,
 29   CAS_FC_DEPRECATED4         : 25,
 30   CAS_FC_SAVEPOINT           : 26,
 31   CAS_FC_PARAMETER_INFO      : 27,
 32   CAS_FC_XA_PREPARE          : 28,
 33   CAS_FC_XA_RECOVER          : 29,
 34   CAS_FC_XA_END_TRAN         : 30,
 35   CAS_FC_CON_CLOSE           : 31,
 36   CAS_FC_CHECK_CAS           : 32,
 37   CAS_FC_MAKE_OUT_RS         : 33,
 38   CAS_FC_GET_GENERATED_KEYS  : 34,
 39   CAS_FC_LOB_NEW             : 35,
 40   CAS_FC_LOB_WRITE           : 36,
 41   CAS_FC_LOB_READ            : 37,
 42   CAS_FC_END_SESSION         : 38,
 43   CAS_FC_GET_ROW_COUNT       : 39,
 44   CAS_FC_GET_LAST_INSERT_ID  : 40,
 45   CAS_FC_PREPARE_AND_EXECUTE : 41
 46 };
 47 
 48 /**
 49  * Define CUBRID Statement types constants
 50  */
 51 exports.CUBRIDStatementType = {
 52   CUBRID_STMT_ALTER_CLASS       : 0,
 53   CUBRID_STMT_ALTER_SERIAL      : 1,
 54   CUBRID_STMT_COMMIT_WORK       : 2,
 55   CUBRID_STMT_REGISTER_DATABASE : 3,
 56   CUBRID_STMT_CREATE_CLASS      : 4,
 57   CUBRID_STMT_CREATE_INDEX      : 5,
 58   CUBRID_STMT_CREATE_TRIGGER    : 6,
 59   CUBRID_STMT_CREATE_SERIAL     : 7,
 60   CUBRID_STMT_DROP_DATABASE     : 8,
 61   CUBRID_STMT_DROP_CLASS        : 9,
 62   CUBRID_STMT_DROP_INDEX        : 10,
 63   CUBRID_STMT_DROP_LABEL        : 11,
 64   CUBRID_STMT_DROP_TRIGGER      : 12,
 65   CUBRID_STMT_DROP_SERIAL       : 13,
 66   CUBRID_STMT_EVALUATE          : 14,
 67   CUBRID_STMT_RENAME_CLASS      : 15,
 68   CUBRID_STMT_ROLLBACK_WORK     : 16,
 69   CUBRID_STMT_GRANT             : 17,
 70   CUBRID_STMT_REVOKE            : 18,
 71   CUBRID_STMT_STATISTICS        : 19,
 72   CUBRID_STMT_INSERT            : 20,
 73   CUBRID_STMT_SELECT            : 21,
 74   CUBRID_STMT_UPDATE            : 22,
 75   CUBRID_STMT_DELETE            : 23,
 76   CUBRID_STMT_CALL              : 24,
 77   CUBRID_STMT_GET_ISO_LVL       : 25,
 78   CUBRID_STMT_GET_TIMEOUT       : 26,
 79   CUBRID_STMT_GET_OPT_LVL       : 27,
 80   CUBRID_STMT_SET_OPT_LVL       : 28,
 81   CUBRID_STMT_SCOPE             : 29,
 82   CUBRID_STMT_GET_TRIGGER       : 30,
 83   CUBRID_STMT_SET_TRIGGER       : 31,
 84   CUBRID_STMT_SAVEPOINT         : 32,
 85   CUBRID_STMT_PREPARE           : 33,
 86   CUBRID_STMT_ATTACH            : 34,
 87   CUBRID_STMT_USE               : 35,
 88   CUBRID_STMT_REMOVE_TRIGGER    : 36,
 89   CUBRID_STMT_RENAME_TRIGGER    : 37,
 90   CUBRID_STMT_ON_LDB            : 38,
 91   CUBRID_STMT_GET_LDB           : 39,
 92   CUBRID_STMT_SET_LDB           : 40,
 93   CUBRID_STMT_GET_STATS         : 41,
 94   CUBRID_STMT_CREATE_USER       : 42,
 95   CUBRID_STMT_DROP_USER         : 43,
 96   CUBRID_STMT_ALTER_USER        : 44,
 97   CUBRID_STMT_CALL_SP           : 0x7e,
 98   CUBRID_STMT_UNKNOWN           : 0x7f
 99 };
100 
101 /**
102  * Define CUBRID Isolation levels constants
103  */
104 exports.CUBRIDIsolationLevel = {
105   TRAN_UNKNOWN_ISOLATION              : 0x00,
106   TRAN_COMMIT_CLASS_UNCOMMIT_INSTANCE : 0x01,
107   TRAN_COMMIT_CLASS_COMMIT_INSTANCE   : 0x02,
108   TRAN_REP_CLASS_UNCOMMIT_INSTANCE    : 0x03,
109   TRAN_REP_CLASS_COMMIT_INSTANCE      : 0x04,
110   TRAN_REP_CLASS_REP_INSTANCE         : 0x05,
111   TRAN_SERIALIZABLE                   : 0x06,
112   TRAN_DEFAULT_ISOLATION              : 0x01
113 };
114 
115 /**
116  * Define CUBRID Data types constants
117  */
118 exports.CUBRIDDataType = {
119   CCI_U_TYPE_UNKNOWN   : 0,
120   CCI_U_TYPE_NULL      : 0,
121   CCI_U_TYPE_CHAR      : 1,
122   CCI_U_TYPE_STRING    : 2,
123   CCI_U_TYPE_NCHAR     : 3,
124   CCI_U_TYPE_VARNCHAR  : 4,
125   CCI_U_TYPE_BIT       : 5,
126   CCI_U_TYPE_VARBIT    : 6,
127   CCI_U_TYPE_NUMERIC   : 7,
128   CCI_U_TYPE_INT       : 8,
129   CCI_U_TYPE_SHORT     : 9,
130   CCI_U_TYPE_MONETARY  : 10,
131   CCI_U_TYPE_FLOAT     : 11,
132   CCI_U_TYPE_DOUBLE    : 12,
133   CCI_U_TYPE_DATE      : 13,
134   CCI_U_TYPE_TIME      : 14,
135   CCI_U_TYPE_TIMESTAMP : 15,
136   CCI_U_TYPE_SET       : 16,
137   CCI_U_TYPE_MULTISET  : 17,
138   CCI_U_TYPE_SEQUENCE  : 18,
139   CCI_U_TYPE_OBJECT    : 19,
140   CCI_U_TYPE_RESULTSET : 20,
141   CCI_U_TYPE_BIGINT    : 21,
142   CCI_U_TYPE_DATETIME  : 22,
143   CCI_U_TYPE_BLOB      : 23,
144   CCI_U_TYPE_CLOB      : 24
145 };
146 
147 /**
148  * Convert data type number to data type name
149  */
150 exports.getCUBRIDDataType = function (type) {
151   switch (type) {
152     case this.CUBRIDDataType.CCI_U_TYPE_CHAR:
153       return 'Char';
154     case this.CUBRIDDataType.CCI_U_TYPE_NCHAR:
155       return 'NChar';
156     case this.CUBRIDDataType.CCI_U_TYPE_STRING:
157       return 'String';
158     case this.CUBRIDDataType.CCI_U_TYPE_VARNCHAR:
159       return 'VarNchar';
160     case this.CUBRIDDataType.CCI_U_TYPE_SHORT:
161       return 'Short';
162     case this.CUBRIDDataType.CCI_U_TYPE_INT:
163       return 'Int';
164     case this.CUBRIDDataType.CCI_U_TYPE_BIGINT:
165       return 'Bigint';
166     case this.CUBRIDDataType.CCI_U_TYPE_FLOAT:
167       return 'Float';
168     case this.CUBRIDDataType.CCI_U_TYPE_DOUBLE:
169       return 'Double';
170     case this.CUBRIDDataType.CCI_U_TYPE_MONETARY:
171       return 'Monetary';
172     case this.CUBRIDDataType.CCI_U_TYPE_NUMERIC:
173       return 'Numeric';
174     case this.CUBRIDDataType.CCI_U_TYPE_DATE:
175       return 'Date';
176     case this.CUBRIDDataType.CCI_U_TYPE_TIME:
177       return 'Time';
178     case this.CUBRIDDataType.CCI_U_TYPE_DATETIME:
179       return 'DateTime';
180     case this.CUBRIDDataType.CCI_U_TYPE_TIMESTAMP:
181       return 'Timestamp';
182     case this.CUBRIDDataType.CCI_U_TYPE_OBJECT:
183       return 'Object';
184     case this.CUBRIDDataType.CCI_U_TYPE_BIT:
185       return 'Bit';
186     case this.CUBRIDDataType.CCI_U_TYPE_VARBIT:
187       return 'Varbit';
188     case this.CUBRIDDataType.CCI_U_TYPE_SET:
189       return 'Set';
190     case this.CUBRIDDataType.CCI_U_TYPE_MULTISET:
191       return 'Multiset';
192     case this.CUBRIDDataType.CCI_U_TYPE_SEQUENCE:
193       return 'Sequence';
194     case this.CUBRIDDataType.CCI_U_TYPE_BLOB:
195       return 'Blob';
196     case this.CUBRIDDataType.CCI_U_TYPE_CLOB:
197       return 'Clob';
198     case this.CUBRIDDataType.CCI_U_TYPE_RESULTSET:
199       return 'Resultset';
200     default:
201       return 'UNKNOWN';
202   }
203 };
204 
205 /**
206  * Define CUBRID Schema type constants
207  */
208 exports.CUBRIDSchemaType = {
209   CCI_SCH_CLASS              : 1,
210   CCI_SCH_VCLASS             : 2,
211   CCI_SCH_QUERY_SPEC         : 3,
212   CCI_SCH_ATTRIBUTE          : 4,
213   CCI_SCH_CLASS_ATTRIBUTE    : 5,
214   CCI_SCH_METHOD             : 6,
215   CCI_SCH_CLASS_METHOD       : 7,
216   CCI_SCH_METHOD_FILE        : 8,
217   CCI_SCH_SUPERCLASS         : 9,
218   CCI_SCH_SUBCLASS           : 10,
219   CCI_SCH_CONSTRAIT          : 11,
220   CCI_SCH_TRIGGER            : 12,
221   CCI_SCH_CLASS_PRIVILEGE    : 13,
222   CCI_SCH_ATTR_PRIVILEGE     : 14,
223   CCI_SCH_DIRECT_SUPER_CLASS : 15,
224   CCI_SCH_PRIMARY_KEY        : 16,
225   CCI_SCH_IMPORTED_KEYS      : 17,
226   CCI_SCH_EXPORTED_KEYS      : 18,
227   CCI_SCH_CROSS_REFERENCE    : 19
228 };
229 
230 /**
231  * Define CUBRID Prepare statement constants
232  */
233 exports.CCIPrepareOption = {
234   CCI_PREPARE_NORMAL      : 0x00,
235   CCI_PREPARE_INCLUDE_OID : 0x01,
236   CCI_PREPARE_UPDATABLE   : 0x02,
237   CCI_PREPARE_QUERY_INFO  : 0x04,
238   CCI_PREPARE_HOLDABLE    : 0x08,
239   CCI_PREPARE_CALL        : 0x40
240 };
241 
242 /**
243  * Define CUBRID OID commands constants
244  */
245 exports.OidCommand = {
246   DROP_BY_OID           : 1,
247   IS_INSTANCE           : 2,
248   GET_READ_LOCK_BY_OID  : 3,
249   GET_WRITE_LOCK_BY_OID : 4,
250   GET_CLASS_NAME_BY_OID : 5
251 };
252 
253 /**
254  * Define CUBRID Transaction type constants
255  */
256 exports.CCITransactionType = {
257   CCI_TRAN_COMMIT   : 1,
258   CCI_TRAN_ROLLBACK : 2
259 };
260 
261 /**
262  * Define CUBRID Database parameters constants
263  */
264 exports.CCIDbParam = {
265   CCI_PARAM_ISOLATION_LEVEL   : 1,
266   CCI_PARAM_LOCK_TIMEOUT      : 2,
267   CCI_PARAM_MAX_STRING_LENGTH : 3,
268   CCI_PARAM_AUTO_COMMIT       : 4
269 };
270 
271 /**
272  * Define CUBRID Collection-related commands constants
273  */
274 exports.CUBRIDCollectionCommand = {
275   GET_COLLECTION_VALUE         : 1,
276   GET_SIZE_OF_COLLECTION       : 2,
277   DROP_ELEMENT_IN_SET          : 3,
278   ADD_ELEMENT_TO_SET           : 4,
279   DROP_ELEMENT_IN_SEQUENCE     : 5,
280   INSERT_ELEMENT_INTO_SEQUENCE : 6,
281   PUT_ELEMENT_ON_SEQUENCE      : 7
282 };
283 
284 /**
285  * Define CUBRID Connection status constants
286  */
287 exports.ConnectionStatus = {
288   CON_STATUS_OUT_TRAN          : 0,
289   CON_STATUS_IN_TRAN           : 1,
290   CON_STATUS_CLOSE             : 2,
291   CON_STATUS_CLOSE_AND_CONNECT : 3
292 };
293 
294 /**
295  * Define CUBRID Cursor position constants
296  */
297 exports.CCICursorPosition = {
298   CCI_CURSOR_FIRST   : 0,
299   CCI_CURSOR_CURRENT : 1,
300   CCI_CURSOR_LAST    : 2
301 };
302 
303 /**
304  * Define CUBRID Statement execution type constants
305  */
306 exports.StmtType = {
307   NORMAL                 : 0,
308   GET_BY_OID             : 1,
309   GET_SCHEMA_INFO        : 2,
310   GET_AUTOINCREMENT_KEYS : 3
311 };
312 
313 /**
314  * Define CUBRID Query execution constants
315  */
316 exports.QueryExecutionMode = {
317   SYNC_EXEC  : 0,
318   ASYNC_EXEC : 1
319 };
320 
321 /**
322  * Define CUBRID Statement execution constants
323  */
324 exports.CCIExecutionOption = {
325   CCI_EXEC_NORMAL          : 0x00,
326   CCI_EXEC_ASYNC           : 0x01,
327   CCI_EXEC_QUERY_ALL       : 0x02,
328   CCI_EXEC_QUERY_INFO      : 0x04,
329   CCI_EXEC_ONLY_QUERY_PLAN : 0x08,
330   CCI_EXEC_THREAD          : 0x10,
331   CCI_EXEC_HOLDABLE        : 0x20
332 };
333 
334