1 #ifndef __Oracle_OciCommon__ 2 #define __Oracle_OciCommon__ 3 4 // excerpt from OCI headers (OCI7 & OCI8) 5 namespace Upp { 6 struct OCIEnv; 7 struct OCIServer; 8 struct OCISession; 9 struct OCIStmt; 10 struct OCIBind; 11 struct OCIDefine; 12 struct OCISnapshot; 13 struct OCIParam; 14 15 INITIALIZE(Oracle) 16 } 17 18 #define oci_boolean int 19 typedef void dvoid; 20 typedef int sword; 21 typedef int sb4; 22 typedef UPP::dword uword; 23 typedef UPP::dword ub4; 24 typedef short sb2; 25 typedef UPP::word ub2; 26 typedef signed char sb1; 27 typedef UPP::byte ub1; 28 typedef UPP::byte OraText; 29 enum 30 { 31 // OCIInitialize modes 32 OCI_THREADED = 0x01, // the application is in threaded environment 33 OCI_OBJECT = 0x02, // the application is in object environment 34 OCI_EVENTS = 0x04, // the application is enabled for events 35 OCI_RESERVED1 = 0x08, // Reserved for internal use 36 OCI_SHARED = 0x10, // the application is in shared mode 37 OCI_RESERVED2 = 0x20, // Reserved for internal use 38 // The following *TWO* are only valid for OCICreateEnvironment call 39 OCI_NO_UCB = 0x40, // No user callback called during init 40 OCI_NO_MUTEX = 0x80, // the environment handle will not be 41 // NLS 42 OCI_NLS_NCHARSET_ID_UT8 = 871, /* AL32UTF8 charset id */ 43 OCI_NLS_NCHARSET_ID_AL32UT8 = 873, /* AL32UTF8 charset id */ 44 // protected by a mutex internally 45 OCI_SHARED_EXT = 0x100, // Used for shared forms 46 OCI_CACHE = 0x200, // used by iCache 47 48 OCI_DEFAULT = 0x00, // the default value for parameters and attributes 49 OCI_DATA_AT_EXEC = 0x02, // data at execute time 50 51 OCI_HTYPE_FIRST = 1, // start value of handle type 52 OCI_HTYPE_ENV = 1, // environment handle 53 OCI_HTYPE_ERROR = 2, // error handle 54 OCI_HTYPE_SVCCTX = 3, // service handle 55 OCI_HTYPE_STMT = 4, // statement handle 56 OCI_HTYPE_BIND = 5, // bind handle 57 OCI_HTYPE_DEFINE = 6, // define handle 58 OCI_HTYPE_DESCRIBE = 7, // describe handle 59 OCI_HTYPE_SERVER = 8, // server handle 60 OCI_HTYPE_SESSION = 9, // authentication handle 61 OCI_HTYPE_TRANS = 10, // transaction handle 62 OCI_HTYPE_COMPLEXOBJECT = 11, // complex object retrieval handle 63 OCI_HTYPE_SECURITY = 12, // security handle 64 OCI_HTYPE_SUBSCRIPTION = 13, // subscription handle 65 OCI_HTYPE_DIRPATH_CTX = 14, // direct path context 66 OCI_HTYPE_DIRPATH_COLUMN_ARRAY = 15, // direct path column array 67 OCI_HTYPE_DIRPATH_STREAM = 16, // direct path stream 68 OCI_HTYPE_PROC = 17, // process handle 69 OCI_HTYPE_LAST = 17, // last value of a handle type 70 71 // input data types 72 SQLT_CHR = 1, // (ORANET TYPE) character string 73 SQLT_NUM = 2, // (ORANET TYPE) oracle numeric 74 SQLT_INT = 3, // (ORANET TYPE) integer 75 SQLT_FLT = 4, // (ORANET TYPE) Floating point number 76 SQLT_STR = 5, // zero terminated string 77 SQLT_VNU = 6, // NUM with preceding length byte 78 SQLT_PDN = 7, // (ORANET TYPE) Packed Decimal Numeric 79 SQLT_LNG = 8, // long 80 SQLT_VCS = 9, // Variable character string 81 SQLT_NON = 10, // Null/empty PCC Descriptor entry 82 SQLT_RID = 11, // rowid 83 SQLT_DAT = 12, // date in oracle format 84 SQLT_VBI = 15, // binary in VCS format 85 SQLT_BIN = 23, // binary data(DTYBIN) 86 SQLT_LBI = 24, // long binary 87 SQLT_UIN = 68, // unsigned integer 88 SQLT_SLS = 91, // Display sign leading separate 89 SQLT_LVC = 94, // Longer longs (char) 90 SQLT_LVB = 95, // Longer long binary 91 SQLT_AFC = 96, // Ansi fixed char 92 SQLT_AVC = 97, // Ansi Var char 93 SQLT_CUR = 102, // cursor type 94 SQLT_RDD = 104, // rowid descriptor 95 SQLT_LAB = 105, // label type 96 SQLT_OSL = 106, // oslabel type 97 98 SQLT_NTY = 108, // named object type 99 SQLT_REF = 110, // ref type 100 SQLT_CLOB = 112, // character lob 101 SQLT_BLOB = 113, // binary lob 102 SQLT_BFILEE = 114, // binary file lob 103 SQLT_CFILEE = 115, // character file lob 104 SQLT_RSET = 116, // result set type 105 SQLT_NCO = 122, // named collection type (varray or nested table) 106 SQLT_VST = 155, // OCIString type 107 SQLT_ODT = 156, // OCIDate type 108 109 // datetimes and intervals 110 SQLT_DATE = 184, // ANSI Date 111 SQLT_TIME = 185, // TIME 112 SQLT_TIME_TZ = 186, // TIME WITH TIME ZONE 113 SQLT_TIMESTAMP = 187, // TIMESTAMP 114 SQLT_TIMESTAMP_TZ = 188, // TIMESTAMP WITH TIME ZONE 115 SQLT_INTERVAL_YM = 189, // INTERVAL YEAR TO MONTH 116 SQLT_INTERVAL_DS = 190, // INTERVAL DAY TO SECOND 117 SQLT_TIMESTAMP_LTZ = 232, // TIMESTAMP WITH LOCAL TZ 118 119 // cxcheng: this has been added for backward compatibility - 120 // it needs to be here because ocidfn.h can get included ahead of sqldef.h 121 SQLT_FILE = SQLT_BFILEE, // binary file lob 122 SQLT_CFILE = SQLT_CFILEE, 123 SQLT_BFILE = SQLT_BFILEE, 124 125 OCI_DTYPE_FIRST = 50, // start value of descriptor type 126 OCI_DTYPE_LOB = 50, // lob locator 127 OCI_DTYPE_SNAP = 51, // snapshot descriptor 128 OCI_DTYPE_RSET = 52, // result set descriptor 129 OCI_DTYPE_PARAM = 53, // a parameter descriptor obtained from ocigparm 130 OCI_DTYPE_ROWID = 54, // rowid descriptor 131 OCI_DTYPE_COMPLEXOBJECTCOMP = 55, 132 // complex object retrieval descriptor 133 OCI_DTYPE_FILE = 56, // File Lob locator 134 OCI_DTYPE_AQENQ_OPTIONS = 57, // enqueue options 135 OCI_DTYPE_AQDEQ_OPTIONS = 58, // dequeue options 136 OCI_DTYPE_AQMSG_PROPERTIES = 59, // message properties 137 OCI_DTYPE_AQAGENT = 60, // aq agent 138 OCI_DTYPE_LOCATOR = 61, // LOB locator 139 OCI_DTYPE_INTERVAL_YM = 62, // Interval year month 140 OCI_DTYPE_INTERVAL_DS = 63, // Interval day second 141 OCI_DTYPE_AQNFY_DESCRIPTOR = 64, // AQ notify descriptor 142 OCI_DTYPE_DATE = 65, // Date 143 OCI_DTYPE_TIME = 66, // Time 144 OCI_DTYPE_TIME_TZ = 67, // Time with timezone 145 OCI_DTYPE_TIMESTAMP = 68, // Timestamp 146 OCI_DTYPE_TIMESTAMP_TZ = 69, // Timestamp with timezone 147 OCI_DTYPE_TIMESTAMP_LTZ = 70, // Timestamp with local tz 148 OCI_DTYPE_UCB = 71, // user callback descdriptor 149 OCI_DTYPE_LAST = 71, // last value of a descriptor type 150 151 OCI_V7_SYNTAX = 2, // V815 language - for backwards compatibility 152 OCI_V8_SYNTAX = 3, // V815 language - for backwards compatibility 153 OCI_NTV_SYNTAX = 1, // Use what so ever is the native lang of server 154 155 OCI_STMT_SELECT = 1, // select statement 156 OCI_STMT_UPDATE = 2, // update statement 157 OCI_STMT_DELETE = 3, // delete statement 158 OCI_STMT_INSERT = 4, // Insert Statement 159 OCI_STMT_CREATE = 5, // create statement 160 OCI_STMT_DROP = 6, // drop statement 161 OCI_STMT_ALTER = 7, // alter statement 162 OCI_STMT_BEGIN = 8, // begin ... (pl/sql statement) 163 OCI_STMT_DECLARE = 9, // declare ... (pl/sql statement) 164 165 OCI_BATCH_MODE = 0x01, // batch the oci statement for execution 166 OCI_EXACT_FETCH = 0x02, // fetch the exact rows specified 167 OCI_KEEP_FETCH_STATE = 0x04, // unused 168 OCI_SCROLLABLE_CURSOR = 0x08, // cursor scrollable 169 OCI_DESCRIBE_ONLY = 0x10, // only describe the statement 170 OCI_COMMIT_ON_SUCCESS = 0x20, // commit, if successful execution 171 OCI_NON_BLOCKING = 0x40, // non-blocking 172 OCI_BATCH_ERRORS = 0x80, // batch errors in array dmls 173 OCI_PARSE_ONLY = 0x100, // only parse the statement 174 OCI_EXACT_FETCH_RESERVED_1 = 0x200, // reserved for internal use 175 OCI_SHOW_DML_WARNINGS = 0x400, 176 177 OCI_SUCCESS = 0, // maps to SQL_SUCCESS of SAG CLI 178 OCI_SUCCESS_WITH_INFO = 1, // maps to SQL_SUCCESS_WITH_INFO 179 OCI_RESERVED_FOR_INT_USE = 200, // reserved for internal use 180 OCI_NO_DATA = 100, // maps to SQL_NO_DATA 181 OCI_ERROR = -1, // maps to SQL_ERROR 182 OCI_INVALID_HANDLE = -2, // maps to SQL_INVALID_HANDLE 183 OCI_NEED_DATA = 99, // maps to SQL_NEED_DATA 184 OCI_STILL_EXECUTING = -3123, // OCI would block error 185 OCI_CONTINUE = -24200, // Continue with the body of the OCI function 186 187 SQLCS_IMPLICIT = 1, // for CHAR, VARCHAR2, CLOB w/o a specified set 188 SQLCS_NCHAR = 2, // for NCHAR, NCHAR VARYING, NCLOB 189 SQLCS_EXPLICIT = 3, // for CHAR, etc, with "CHARACTER SET ..." syntax 190 SQLCS_FLEXIBLE = 4, // for PL/SQL "flexible" parameters 191 SQLCS_LIT_NULL = 5, // for typecheck of NULL and empty_clob() lits 192 193 OCI_FETCH_NEXT = 0x02, // next row 194 OCI_FETCH_FIRST = 0x04, // first row of the result set 195 OCI_FETCH_LAST = 0x08, // the last row of the result set 196 OCI_FETCH_PRIOR = 0x10, // the previous row relative to current 197 OCI_FETCH_ABSOLUTE = 0x20, // absolute offset from first 198 OCI_FETCH_RELATIVE = 0x40, // offset relative to current 199 OCI_FETCH_RESERVED_1 = 0x80, // reserved for internal use 200 201 OCI_ONE_PIECE = 0, // one piece 202 OCI_FIRST_PIECE = 1, // the first piece 203 OCI_NEXT_PIECE = 2, // the next of many pieces 204 OCI_LAST_PIECE = 3, // the last piece 205 206 OCI_ATTR_DATA_SIZE = 1, // maximum size of the data 207 OCI_ATTR_DATA_TYPE = 2, // the SQL type of the column/argument 208 OCI_ATTR_NAME = 4, // the name of the column/argument 209 OCI_ATTR_PRECISION = 5, // precision if number type 210 OCI_ATTR_SCALE = 6, // scale if number type 211 OCI_ATTR_ROW_COUNT = 9, // the rows processed so far 212 OCI_ATTR_PREFETCH_ROWS = 11, // sets the number of rows to prefetch 213 OCI_ATTR_STMT_TYPE = 24, // statement type 214 OCI_ATTR_PARAM_COUNT = 18, // number of column in the select list 215 216 OCI_ATTR_ENV = 5, // the environment handle 217 OCI_ATTR_SERVER = 6, // the server handle 218 OCI_ATTR_SESSION = 7, // the user session handle 219 220 OCI_ATTR_USERNAME = 22, // username attribute 221 OCI_ATTR_PASSWORD = 23, // password attribute 222 223 OCI_CRED_RDBMS = 1, // database username/password 224 225 OCI_LM_DEF = 0, // default login 226 OCI_LM_NBL = 1, // non-blocking logon 227 228 OCI_STRING_MAXLEN = 4000, // default maximum length of a vstring 229 }; 230 231 #if defined(SS_64BIT_SERVER) || defined(__64BIT__) 232 #define CDA_SIZE 88 233 #else 234 # define CDA_SIZE 64 235 #endif 236 237 struct cda_head { 238 sb2 v2_rc; 239 ub2 ft; 240 ub4 rpc; 241 ub2 peo; 242 ub1 fc; 243 ub1 rcs1; 244 ub2 rc; 245 ub1 wrn; 246 ub1 rcs2; 247 sword rcs3; 248 struct { 249 struct { 250 ub4 rcs4; 251 ub2 rcs5; 252 ub1 rcs6; 253 } rd; 254 ub4 rcs7; 255 ub2 rcs8; 256 } rid; 257 sword ose; 258 ub1 chk; 259 dvoid *rcsp; 260 }; 261 262 struct cda_def { 263 sb2 v2_rc; /* V2 return code */ 264 ub2 ft; /* SQL function type */ 265 ub4 rpc; /* rows processed count */ 266 ub2 peo; /* parse error offset */ 267 ub1 fc; /* OCI function code */ 268 ub1 rcs1; /* filler area */ 269 ub2 rc; /* V7 return code */ 270 ub1 wrn; /* warning flags */ 271 ub1 rcs2; /* reserved */ 272 sword rcs3; /* reserved */ 273 struct { /* rowid structure */ 274 struct { 275 ub4 rcs4; 276 ub2 rcs5; 277 ub1 rcs6; 278 } rd; 279 ub4 rcs7; 280 ub2 rcs8; 281 } rid; 282 sword ose; /* OSD dependent error */ 283 ub1 chk; 284 dvoid *rcsp; /* pointer to reserved area */ 285 ub1 rcs9[CDA_SIZE - sizeof (struct cda_head)]; /* filler */ 286 }; 287 288 typedef sb4 (*OCICallbackInBind)(dvoid *ictxp, UPP::OCIBind *bindp, ub4 iter, 289 ub4 index, dvoid **bufpp, ub4 *alenp, 290 ub1 *piecep, dvoid **indp); 291 292 typedef sb4 (*OCICallbackOutBind)(dvoid *octxp, UPP::OCIBind *bindp, ub4 iter, 293 ub4 index, dvoid **bufpp, ub4 **alenp, 294 ub1 *piecep, dvoid **indp, 295 ub2 **rcodep); 296 297 #endif//__Oracle_OciCommon__ 298