Tang Cheng | 31b9525 | 2014-10-23 09:22:35 +0800 | [diff] [blame^] | 1 | /* Copyright (c) 1981, 2005, Oracle. All rights reserved. */ |
| 2 | /* Copyright (c) 1984, 2005, Oracle. All rights reserved. */ |
| 3 | |
| 4 | /* |
| 5 | NAME |
| 6 | ocidef |
| 7 | CONTENTS |
| 8 | Oracle Call Interface cursor area and LDA definitions |
| 9 | NOTES |
| 10 | none |
| 11 | OWNER |
| 12 | Oates |
| 13 | DATE |
| 14 | 09/07/82 |
| 15 | MODIFIED |
| 16 | mbastawa 09/16/05 - dbhygiene |
| 17 | dmukhin 06/29/05 - ANSI prototypes; miscellaneous cleanup |
| 18 | srseshad 03/25/03 - convert oci public api to ansi |
| 19 | csteinba 11/05/02 - bug 2521931: redefine OTYACL |
| 20 | aahluwal 06/03/02 - bug 2360115 |
| 21 | bpalaval 02/08/01 - Change text to oratext. |
| 22 | chliang 02/01/01 - fix olint error. |
| 23 | bpalaval 11/16/00 - Bug 1244685 : Fix ALTER CLUSTER issue.. |
| 24 | slari 11/08/00 - remove functions duplicated in ociapr.h |
| 25 | whe 09/01/99 - 976457:check __cplusplus for C++ code |
| 26 | skmishra 04/23/97 - Provide C++ compatibility |
| 27 | lchidamb 06/26/96 - put upidef.h, riddef.h within #ifndef |
| 28 | slari 06/12/96 - add ocigft_getFcnType |
| 29 | dchatter 11/10/95 - ocignfd - oci get native file descriptor |
| 30 | slari 05/11/95 - change OCIEVDEF/OCIEVTSF to UPIEVDEF/UPIEVTSF |
| 31 | dchatter 04/06/95 - add ifdef flags around OCI_flags |
| 32 | lchidamb 04/06/95 - drop maxdsz from ocibndps/ocidfnps |
| 33 | slari 04/07/95 - rename opinit to ocipin |
| 34 | slari 03/13/95 - thread safety changes |
| 35 | dchatter 03/08/95 - piece definitions OCI_*_PIECE |
| 36 | lchidamb 12/06/94 - add support for binding/defining with skips |
| 37 | dchatter 03/06/95 - merge changes from branch 1.12.720.1 |
| 38 | dchatter 02/06/95 - add defines for login mode parameters |
| 39 | dchatter 07/06/94 - Deleting CRSCHK, with refcursor, no way to set this |
| 40 | dchatter 06/13/94 - add a new LDA flag LDANBL |
| 41 | rkooi 11/18/92 - update ocidpr interface |
| 42 | mmoore 10/31/92 - add ocidpr |
| 43 | gpongrac 11/17/92 - fix oexfet prototype |
| 44 | sjain 01/03/92 - Add ocibra |
| 45 | rjenkins 11/04/91 - adding prototypes for oparse and oexfet |
| 46 | sjain 04/15/91 - Change ocistf proto |
| 47 | sjain 04/01/91 - Rearrange oty codes. Add new ones |
| 48 | Jain 12/03/90 - Add #define for new describe call |
| 49 | Jain 11/29/90 - Add new function code for the new oci calls |
| 50 | Mendels 01/20/89 - fix 19170: make ocitbl CONST_DATA |
| 51 | Kabcene 01/27/88 - change interfaces to match V5 |
| 52 | Navab 12/09/87 - add a parameter to ocierr call |
| 53 | Navab 11/30/87 - add ocierr, rename ocioer |
| 54 | Navab 10/08/87 - add prototypes for procedure declarations |
| 55 | Howard 09/07/87 - endif blah |
| 56 | Howard 05/11/87 - Add OTY types |
| 57 | Howard 04/27/87 - move ocldef defines here |
| 58 | Oates 10/15/85 - Add OCANCEL |
| 59 | Oates 09/30/85 - Implement ORA*Net |
| 60 | Oates 06/27/85 - Make datatype compatible with upidef.h |
| 61 | Andy 05/07/85 - delete CSRFBPIC |
| 62 | */ |
| 63 | |
| 64 | #ifndef UPIDEF |
| 65 | #include <upidef.h> |
| 66 | #endif |
| 67 | |
| 68 | #ifndef RIDDEF |
| 69 | #include <riddef.h> |
| 70 | #endif |
| 71 | |
| 72 | #include <ociapr.h> |
| 73 | |
| 74 | #ifndef OCIDEF |
| 75 | #define OCIDEF |
| 76 | |
| 77 | |
| 78 | #define CSRCHECK 172 /* csrdef is a cursor */ |
| 79 | #define LDACHECK 202 /* csrdef is a login data area */ |
| 80 | struct csrdef |
| 81 | { |
| 82 | sb2 csrrc; /* return code: v2 codes, v4 codes negative */ |
| 83 | ub2 csrft; /* function type */ |
| 84 | ub4 csrrpc; /* rows processed count */ |
| 85 | ub2 csrpeo; /* parse error offset */ |
| 86 | ub1 csrfc; /* function code */ |
| 87 | ub1 csrlfl; /* lda flag to indicate type of login */ |
| 88 | ub2 csrarc; /* actual untranslated return code */ |
| 89 | ub1 csrwrn; /* warning flags */ |
| 90 | ub1 csrflg; /* error action */ |
| 91 | sword csrcn; /* cursor number */ |
| 92 | riddef csrrid; /* rowid structure */ |
| 93 | sword csrose; /* os dependent error code */ |
| 94 | ub1 csrchk; /* check byte = CSRCHECK - in cursor */ |
| 95 | /* check byte = LDACHECK - in LDA */ |
| 96 | struct hstdef *csrhst; /* pointer to the hst */ |
| 97 | }; |
| 98 | typedef struct csrdef csrdef; |
| 99 | typedef struct csrdef ldadef; /* lda is the same as a csr */ |
| 100 | |
| 101 | |
| 102 | /* values for csrlfl */ |
| 103 | #define LDAFLG 1 /* ...via ologon */ |
| 104 | #define LDAFLO 2 /* ...via olon or orlon */ |
| 105 | #define LDANBL 3 /* ...nb logon in progress */ |
| 106 | |
| 107 | /* valuses for crsfc */ |
| 108 | #define csrfpa 2 /* ...OSQL */ |
| 109 | #define csrfex 4 /* ...OEXEC */ |
| 110 | #define csrfbi 6 /* ...OBIND */ |
| 111 | #define csrfdb 8 /* ...ODFINN */ |
| 112 | #define csrfdi 10 /* ...ODSRBN */ |
| 113 | #define csrffe 12 /* ...OFETCH */ |
| 114 | #define csrfop 14 /* ...OOPEN */ |
| 115 | #define csrfcl 16 /* ...OCLOSE */ |
| 116 | #define csrfds 22 /* ...ODSC */ |
| 117 | #define csrfnm 24 /* ...ONAME */ |
| 118 | #define csrfp3 26 /* ...OSQL3 */ |
| 119 | #define csrfbr 28 /* ...OBNDRV */ |
| 120 | #define csrfbx 30 /* ...OBNDRN */ |
| 121 | /*#defe csrfdf 32*/ /* ???? */ |
| 122 | #define csrfso 34 /* ...OOPT */ |
| 123 | #define csrfre 36 /* ...ORESUM */ |
| 124 | #define csrfbn 50 /* ...OBINDN */ |
| 125 | #define csrfca 52 /* ..OCANCEL */ |
| 126 | #define csrfsd 54 /* ..OSQLD */ |
| 127 | #define csrfef 56 /* ..OEXFEN */ |
| 128 | #define csrfln 58 /* ..OFLNG */ |
| 129 | #define csrfdp 60 /* ..ODSCSP */ |
| 130 | #define csrfba 62 /* ..OBNDRA */ |
| 131 | #define csrfbps 63 /*..OBINDPS */ |
| 132 | #define csrfdps 64 /*..ODEFINPS */ |
| 133 | #define csrfgpi 65 /* ...OGETPI */ |
| 134 | #define csrfspi 66 /* ...OSETPI */ |
| 135 | |
| 136 | /* values for csrwrn */ |
| 137 | #define CSRWANY 0x01 /* there is a warning flag set */ |
| 138 | #define CSRWTRUN 0x02 /* a data item was truncated */ |
| 139 | #define CSRWNVIC 0x04 /* NULL values were used in an aggregate function */ |
| 140 | #define CSRWITCE 0x08 /* column count not equal to into list count */ |
| 141 | #define CSRWUDNW 0x10 /* update or delete without where clause */ |
| 142 | #define CSRWRSV0 0x20 |
| 143 | #define CSRWROLL 0x40 /* rollback required */ |
| 144 | #define CSRWRCHG 0x80 /* change after query start on select for update */ |
| 145 | |
| 146 | /* values fro csrflg */ |
| 147 | #define CSRFSPND 0x01 /* current operation suspended */ |
| 148 | #define CSRFATAL 0x02 /* fatal operation: transaction rolled back */ |
| 149 | #define CSRFBROW 0x04 /* current row backed out */ |
| 150 | #define CSRFREFC 0x08 /* ref cursor type CRSCHK disabled for this cursor */ |
| 151 | #define CSRFNOAR 0x10 /* ref cursor type binds, so no array bind/execute */ |
| 152 | |
| 153 | /* define function codes; in order of octdef.h */ |
| 154 | #define OTYCTB 1 /* CREATE TABLE */ |
| 155 | #define OTYSER 2 /* set role */ |
| 156 | #define OTYINS 3 /* INSERT */ |
| 157 | #define OTYSEL 4 /* SELECT */ |
| 158 | #define OTYUPD 5 /* UPDATE */ |
| 159 | #define OTYDRO 6 /* drop role */ |
| 160 | #define OTYDVW 7 /* DROP VIEW */ |
| 161 | /* once was validate index */ |
| 162 | /* once was create partition */ |
| 163 | /* once was alter partition */ |
| 164 | #define OTYDTB 8 /* DROP TABLE */ |
| 165 | /* once was alter space */ |
| 166 | /* once was drop space */ |
| 167 | #define OTYDEL 9 /* DELETE */ |
| 168 | #define OTYCVW 10 /* create view */ |
| 169 | #define OTYDUS 11 /* drop user */ |
| 170 | #define OTYCRO 12 /* create role */ |
| 171 | #define OTYCSQ 13 /* create sequence */ |
| 172 | #define OTYASQ 14 /* alter sequence */ |
| 173 | #define OTYACL 15 /* alter cluster */ |
| 174 | #define OTYDSQ 16 /* drop sequence */ |
| 175 | #define OTYCSC 17 /* create schema */ |
| 176 | #define OTYCCL 18 /* CREATE CLUSTER */ |
| 177 | /* once was alter cluster */ |
| 178 | #define OTYCUS 19 /* create user */ |
| 179 | #define OTYCIX 20 /* CREATE INDEX */ |
| 180 | #define OTYDIX 21 /* DROP INDEX */ |
| 181 | #define OTYDCL 22 /* DROP CLUSTER */ |
| 182 | #define OTYVIX 23 /* validate index */ |
| 183 | #define OTYCPR 24 /* create procedure */ |
| 184 | #define OTYAPR 25 /* alter procedure */ |
| 185 | #define OTYATB 26 /* alter table */ |
| 186 | /* once was evaluate */ |
| 187 | #define OTYXPL 27 /* explain */ |
| 188 | #define OTYGRA 28 /* grant */ |
| 189 | #define OTYREV 29 /* revoke */ |
| 190 | #define OTYCSY 30 /* create synonym */ |
| 191 | #define OTYDSY 31 /* drop synonym */ |
| 192 | #define OTYASY 32 /* alter system switch log */ |
| 193 | #define OTYSET 33 /* set transaction */ |
| 194 | #define OTYPLS 34 /* pl/sql execute */ |
| 195 | #define OTYLTB 35 /* lock */ |
| 196 | #define OTYNOP 36 /* noop */ |
| 197 | #define OTYRNM 37 /* rename */ |
| 198 | #define OTYCMT 38 /* comment */ |
| 199 | #define OTYAUD 39 /* audit */ |
| 200 | #define OTYNOA 40 /* no audit */ |
| 201 | #define OTYAIX 41 /* ALTER INDEX */ |
| 202 | #define OTYCED 42 /* create external database */ |
| 203 | #define OTYDED 43 /* drop external database */ |
| 204 | #define OTYCDB 44 /* create database */ |
| 205 | #define OTYADB 45 /* alter database */ |
| 206 | #define OTYCRS 46 /* create rollback segment */ |
| 207 | #define OTYARS 47 /* alter rollback segment */ |
| 208 | #define OTYDRS 48 /* drop rollback segment */ |
| 209 | #define OTYCTS 49 /* create tablespace */ |
| 210 | #define OTYATS 50 /* alter tablespace */ |
| 211 | #define OTYDTS 51 /* drop tablespace */ |
| 212 | #define OTYASE 52 /* alter session */ |
| 213 | #define OTYAUR 53 /* alter user */ |
| 214 | #define OTYCWK 54 /* commit (work) */ |
| 215 | #define OTYROL 55 /* rollback */ |
| 216 | #define OTYSPT 56 /* savepoint */ |
| 217 | |
| 218 | /* For number greater than 56 the the type is the same as defined in |
| 219 | ** octdef.h for that number. So for completion look at octdef.h |
| 220 | */ |
| 221 | |
| 222 | #define OTYDEV OTYCVW /* old DEFINE VIEW = create view */ |
| 223 | |
| 224 | /* FUNCTION CODES */ |
| 225 | #define OCLFPA 2 /* parse - OSQL */ |
| 226 | #define OCLFEX 4 /* execute - OEXEC */ |
| 227 | #define OCLFBI 6 /* BIND by name - OBIND */ |
| 228 | #define OCLFDB 8 /* define buffer - ODEFIN */ |
| 229 | #define OCLFDI 10 /* describe item - ODSC */ |
| 230 | #define OCLFFE 12 /* fetch - OFETCH */ |
| 231 | #define OCLFOC 14 /* open cursor - OOPEN */ |
| 232 | # define OCLFLI OCLFOC /* old name for open cursor - OOPEN */ |
| 233 | #define OCLFCC 16 /* close cursor - OCLOSE */ |
| 234 | # define OCLFLO OCLFCC /* old name for close cursor - OCLOSE */ |
| 235 | #define OCLFDS 22 /* describe - ODSC */ |
| 236 | #define OCLFON 24 /* get table and column names - ONAME */ |
| 237 | #define OCLFP3 26 /* parse - OSQL3 */ |
| 238 | #define OCLFBR 28 /* bind reference by name - OBNDRV */ |
| 239 | #define OCLFBX 30 /* bind referecne numeric - OBNDRN */ |
| 240 | #define OCLFSO 34 /* special function - OOPT */ |
| 241 | #define OCLFRE 36 /* resume - ORESUM */ |
| 242 | #define OCLFBN 50 /* bindn */ |
| 243 | #define OCLFMX 52 /* maximum function number */ |
| 244 | |
| 245 | #ifdef NEVER /* unused codes */ |
| 246 | # define OCLFLK 18 /* open for kernel operations */ |
| 247 | # define OCLFEK 20 /* execute kernel operations */ |
| 248 | # define OCLFOK 22 /* kernel close */ |
| 249 | # define OCLFIN 28 /* logon to oracle */ |
| 250 | # define OCLFOF 30 /* logoff from oracle */ |
| 251 | # define OCLFAX 32 /* allocate a context area */ |
| 252 | # define OCLFPI 34 /* page in context area */ |
| 253 | # define OCLFIS 36 /* special system logon */ |
| 254 | # define OCLFCO 38 /* cancel the current operation */ |
| 255 | # define OCLFGI 40 /* get database id */ |
| 256 | # define OCLFJN 42 /* journal operation */ |
| 257 | # define OCLFCL 44 /* cleanup prior execute operation */ |
| 258 | # define OCLFMC 46 /* map a cursor area */ |
| 259 | # define OCLFUC 48 /* unmap cursor and restore user maping */ |
| 260 | #endif /*NEVER *//* obsolete codes */ |
| 261 | |
| 262 | |
| 263 | /* values for ocimode in ocipin call */ |
| 264 | |
| 265 | #define OCIEVDEF UPIEVDEF /* default : non-thread safe enivronment */ |
| 266 | #define OCIEVTSF UPIEVTSF /* thread-safe environment */ |
| 267 | |
| 268 | |
| 269 | /* OCIL* flags used to determine the mode of login, using ocilog(). |
| 270 | ** Currently defined only for non-blocking and thread-safe logins. |
| 271 | */ |
| 272 | |
| 273 | #define OCILMDEF UPILMDEF /* default, regular login */ |
| 274 | #define OCILMNBL UPILMNBL /* non-blocking logon */ |
| 275 | #define OCILMESY UPILMESY /* thread safe but external sync */ |
| 276 | #define OCILMISY UPILMISY /* internal sync, we do it */ |
| 277 | #define OCILMTRY UPILMTRY /* try to, but do not block on mutex */ |
| 278 | |
| 279 | |
| 280 | /* |
| 281 | * since sqllib uses both ocidef and ocidfn the following defines |
| 282 | * need to be guarded |
| 283 | */ |
| 284 | #ifndef OCI_FLAGS |
| 285 | #define OCI_FLAGS |
| 286 | |
| 287 | /* OCI_*_PIECE defines the piece types that are returned or set |
| 288 | */ |
| 289 | |
| 290 | #define OCI_ONE_PIECE UPI_ONE_PIECE /* there or this is the only piece */ |
| 291 | #define OCI_FIRST_PIECE UPI_FIRST_PIECE /* the first of many pieces */ |
| 292 | #define OCI_NEXT_PIECE UPI_NEXT_PIECE /* the next of many pieces */ |
| 293 | #define OCI_LAST_PIECE UPI_LAST_PIECE /* the last piece of this column */ |
| 294 | #endif |
| 295 | |
| 296 | /* |
| 297 | ** OCITAB: define return code pairs for version 2 to 3 conversions |
| 298 | */ |
| 299 | struct ocitab |
| 300 | { |
| 301 | sb2 ocitv3; /* Version 3/4 return code */ |
| 302 | sb2 ocitv2; /* Version 2 equivalent return code */ |
| 303 | }; |
| 304 | typedef struct ocitab ocitab; |
| 305 | |
| 306 | externref const ocitab ocitbl[]; |
| 307 | |
| 308 | /* macros to check cursors and LDA's. */ |
| 309 | /* macros to set error codes */ |
| 310 | |
| 311 | # define CRSCHK(c) if ((c->csrchk != CSRCHECK)\ |
| 312 | && !bit(c->csrflg, CSRFREFC))\ |
| 313 | return(ocir32(c, OER(1001))) |
| 314 | # define ldaerr(l, e) ( l->csrrc = (sb2)(-( l->csrarc = (ub2)(e)) ) ) |
| 315 | # define LDACHK(l) if (l->csrchk != LDACHECK) \ |
| 316 | return(ldaerr(l, OER(1001))) |
| 317 | |
| 318 | |
| 319 | /************************************************/ |
| 320 | /* OCI PROCEDURE DECLARATIONS */ |
| 321 | /************************************************/ |
| 322 | |
| 323 | |
| 324 | |
| 325 | |
| 326 | /*****************************/ |
| 327 | /* Database logon/logout */ |
| 328 | /*****************************/ |
| 329 | sword ocilog( ldadef *lda, struct hstdef *hst, oratext *uid, sword uidl, |
| 330 | oratext *psw, sword pswl, oratext* conn, sword connl, |
| 331 | ub4 mode ); |
| 332 | sword ocilon( ldadef *lda, oratext *uid, sword uidl, oratext *psw, |
| 333 | sword pswl, sword audit ); |
| 334 | sword ocilgi( ldadef *lda, sb2 areacount ); |
| 335 | sword ocirlo( ldadef *lda, struct hstdef *hst, oratext *uid, sword uidl, |
| 336 | oratext *psw, sword pswl, sword audit ); |
| 337 | /* ocilon - logon to oracle |
| 338 | ** ocilgi - version 2 compatible ORACLE logon call. |
| 339 | ** no login to ORACLE is performed: the LDA is initialized |
| 340 | ** ocirlo - version 5 compatible ORACLE Remote Login call, |
| 341 | ** oracle login is executed. |
| 342 | ** lda - pointer to ldadef |
| 343 | ** uid - user id [USER[/PASSWORD]] |
| 344 | ** uidl - length of uid, if -1 strlen(uid) is used |
| 345 | ** psw - password string; ignored if specified in uid |
| 346 | ** pswl - length of psw, if -1 strlen(psw) is used |
| 347 | ** audit - is not supported; the only permissible value is 0 |
| 348 | ** areacount - unused |
| 349 | */ |
| 350 | |
| 351 | sword ocilof( ldadef *lda ); |
| 352 | /* |
| 353 | ** ocilof - disconnect from ORACLE |
| 354 | ** lda - pointer to ldadef |
| 355 | */ |
| 356 | |
| 357 | |
| 358 | /*********************/ |
| 359 | /* Error Messages */ |
| 360 | /*********************/ |
| 361 | sword ocierr( ldadef *lda, sb2 rcode, oratext *buffer, sword bufl ); |
| 362 | sword ocidhe( sb2 rcode, oratext *buffer ); |
| 363 | /* |
| 364 | ** Move the text explanation for an ORACLE error to a user defined buffer |
| 365 | ** ocierr - will return the message associated with the hstdef stored |
| 366 | ** in the lda. |
| 367 | ** ocidhe - will return the message associated with the default host. |
| 368 | ** lda - lda associated with the login session |
| 369 | ** rcode - error code as returned by V3 call interface |
| 370 | ** buffer - address of a user buffer of at least 132 characters |
| 371 | */ |
| 372 | |
| 373 | |
| 374 | /***********************/ |
| 375 | /* Cursor Open/Close */ |
| 376 | /***********************/ |
| 377 | sword ociope( struct csrdef *cursor, ldadef *lda, oratext *dbn, sword dbnl, |
| 378 | sword areasize, oratext *uid, sword uidl ); |
| 379 | |
| 380 | sword ociclo( struct csrdef *cursor ); |
| 381 | /* |
| 382 | ** open or close a cursor. |
| 383 | ** cursor - pointer to csrdef |
| 384 | ** ldadef - pointer to ldadef |
| 385 | ** dbn - unused |
| 386 | ** dbnl - unused |
| 387 | ** areasize - if (areasize == -1) areasize <- system default initial size |
| 388 | ** else if (areasize IN [1..256]) areasize <- areasize * 1024; |
| 389 | ** most applications should use the default size since context |
| 390 | ** areas are extended as needed until memory is exhausted. |
| 391 | ** uid - user id |
| 392 | ** uidl - userid length |
| 393 | */ |
| 394 | |
| 395 | /***********************************/ |
| 396 | /* CONTROL AND OPTIONS */ |
| 397 | /***********************************/ |
| 398 | sword ocibre( ldadef *lda ); |
| 399 | /* |
| 400 | ** ocibrk - Oracle Call Interface send BReaK Sends a break to |
| 401 | ** oracle. If oracle is active, the current operation is |
| 402 | ** cancelled. May be called asynchronously. DOES NOT SET |
| 403 | ** OERRCD in the hst. This is because ocibrk may be called |
| 404 | ** asynchronously. Callers must test the return code. |
| 405 | ** lda - pointer to a ldadef |
| 406 | */ |
| 407 | |
| 408 | sword ocican( struct csrdef *cursor ); |
| 409 | /* |
| 410 | ** cancel the operation on the cursor, no additional OFETCH calls |
| 411 | ** will be issued for the existing cursor without an intervening |
| 412 | ** OEXEC call. |
| 413 | ** cursor - pointer to csrdef |
| 414 | */ |
| 415 | |
| 416 | sword ocisfe( struct csrdef *cursor, sword erropt, sword waitopt ); |
| 417 | /* |
| 418 | ** ocisfe - user interface set error options |
| 419 | ** set the error and cursor options. |
| 420 | ** allows user to set the options for dealing with fatal dml errors |
| 421 | ** and other cursor related options |
| 422 | ** see oerdef for valid settings |
| 423 | ** cursor - pointer to csrdef |
| 424 | ** erropt - error optionsn |
| 425 | ** waitopr - wait options |
| 426 | */ |
| 427 | |
| 428 | |
| 429 | /***************************************/ |
| 430 | /* COMMIT/ROLLBACK/AUTOCOMMIT */ |
| 431 | /***************************************/ |
| 432 | sword ocicom( ldadef *lda ); |
| 433 | sword ocirol( ldadef *lda ); |
| 434 | /* |
| 435 | ** ocicom - commit the current transaction |
| 436 | ** ocirol - roll back the current transaction |
| 437 | */ |
| 438 | |
| 439 | sword ocicon( ldadef *lda ); |
| 440 | sword ocicof( ldadef *lda ); |
| 441 | /* |
| 442 | ** ocicon - auto Commit ON |
| 443 | ** ocicof - auto Commit OFf |
| 444 | */ |
| 445 | |
| 446 | |
| 447 | |
| 448 | /************************/ |
| 449 | /* parsing */ |
| 450 | /************************/ |
| 451 | sword ocisq3(struct csrdef *cursor, oratext * /* sqlstm */, sword sqllen); |
| 452 | /* |
| 453 | ** ocisq3 - user interface parse sql statement |
| 454 | ** cursor - pointer to csrdef |
| 455 | ** sqlstm - pointer to SQL statement |
| 456 | ** sqllen - length of SQL statement. if -1, strlen(sqlstm) is used |
| 457 | */ |
| 458 | |
| 459 | |
| 460 | |
| 461 | /***************************/ |
| 462 | /* BINDING */ |
| 463 | /***************************/ |
| 464 | /* these are for the opcode in ocibndps, ocidfnps */ |
| 465 | #define OCI_PCWS 0 |
| 466 | #define OCI_SKIP 1 |
| 467 | |
| 468 | sword ocibin( struct csrdef *cursor, oratext *sqlvar, sword sqlvl, |
| 469 | ub1 *progv, sword progvl, sword ftype, sword scale, |
| 470 | oratext *fmt, sword fmtl, sword fmtt ); |
| 471 | sword ocibrv( struct csrdef *cursor, oratext *sqlvar, sword sqlvl, |
| 472 | ub1 *progv, sword progvl, sword ftype, sword scale, sb2 *indp, |
| 473 | oratext *fmt, sword fmtl, sword fmtt ); |
| 474 | sword ocibra( struct csrdef *cursor, oratext *sqlvar, sword sqlvl, |
| 475 | ub1 *progv, sword progvl, sword ftype, sword scale, |
| 476 | sb2 *indp, ub2 *aln, ub2 *rcp, ub4 mal, ub4 *cal, |
| 477 | oratext *fmt, sword fmtl, sword fmtt ); |
| 478 | sword ocibndps( struct csrdef *cursor, ub1 opcode, oratext *sqlvar, |
| 479 | sb4 sqlvl, ub1 *progv, sb4 progvl, sword ftype, |
| 480 | sword scale, sb2 *indp, ub2 *aln, ub2 *rcp, sb4 pv_skip, |
| 481 | sb4 ind_skip, sb4 len_skip, sb4 rc_skip, ub4 mal, |
| 482 | ub4 *cal, oratext *fmt, sb4 fmtl, sword fmtt ); |
| 483 | sword ocibnn ( struct csrdef *cursor, ub2 sqlvn, ub1 *progv, sword progvl, |
| 484 | sword ftype, sword scale, oratext *fmt, sword fmtl, |
| 485 | sword fmtt ); |
| 486 | sword ocibrn( struct csrdef *cursor, sword sqlvn, ub1 *progv, sword progvl, |
| 487 | sword ftype, sword scale, sb2 *indp, oratext *fmt, sword fmtl, |
| 488 | sword fmtt ); |
| 489 | /* |
| 490 | ** ocibin - bind by value by name |
| 491 | ** ocibrv - bind by reference by name |
| 492 | ** ocibra - bind by reference by name (array) |
| 493 | ** ocibndps - bind by reference by name (array) piecewise or with skips |
| 494 | ** ocibnn - bind by value numeric |
| 495 | ** ocibrn - bind by reference numeric |
| 496 | ** |
| 497 | ** the contents of storage specified in bind-by-value calls are |
| 498 | ** evaluated immediately. |
| 499 | ** the addresses of storage specified in bind-by-reference calls are |
| 500 | ** remembered, and the contents are examined at every execute. |
| 501 | ** |
| 502 | ** cursor - pointer to csrdef |
| 503 | ** sqlvn - the number represented by the name of the bind variables |
| 504 | ** for variables of the form :n or &n for n in [1..256) |
| 505 | ** (i.e. &1, :234). unnecessarily using larger numbers |
| 506 | ** in the range wastes space. |
| 507 | ** sqlvar - the name of the bind variable (:name or &name) |
| 508 | ** sqlval - the length of the name; |
| 509 | ** in bindif -1, strlen(bvname) is used |
| 510 | ** progv - pointer to the object to bind. |
| 511 | ** progvl - length of object to bind. |
| 512 | ** in bind-by-value if specified as -1 then strlen(bfa) is |
| 513 | ** used (really only makes sends with character types) |
| 514 | ** in bind-by-value, if specified as -1 then UB2MAXVAL |
| 515 | ** is used. Again this really makes sense only with |
| 516 | ** SQLT_STR. |
| 517 | ** ftype - datatype of object |
| 518 | ** indp - pointer to indicator variable. |
| 519 | ** -1 means to ignore bfa/bfl and bind NULL; |
| 520 | ** not -1 means to bind the contents of bfa/bfl |
| 521 | ** bind the contents pointed to by bfa |
| 522 | ** aln - Alternate length pointer |
| 523 | ** rcp - Return code pointer |
| 524 | ** mal - Maximum array length |
| 525 | ** cal - Current array length pointer |
| 526 | ** fmt - format string |
| 527 | ** fmtl - length of format string; if -1, strlen(fmt) is used |
| 528 | ** fmtt - desired output type after applying forat mask. Not |
| 529 | ** really yet implemented |
| 530 | ** scale - number of decimal digits in a cobol packed decimal (type 7) |
| 531 | ** |
| 532 | ** Note that the length of bfa when bound as SQLT_STR is reduced |
| 533 | ** to strlen(bfa). |
| 534 | ** Note that trailing blanks are stripped of storage of SQLT_STR. |
| 535 | */ |
| 536 | |
| 537 | /***************************/ |
| 538 | /* DESCRIBING */ |
| 539 | /***************************/ |
| 540 | sword ocidsc ( struct csrdef *cursor, sword pos, sb2 *dbsize, sb2 *fsize, |
| 541 | sb2 *rcode, sb2 *dtype, sb1 *buf, sb2 *bufl, sb2 *dsize ); |
| 542 | sword ocidsr( struct csrdef *cursor, sword pos, sb2 *dbsize, sb2 *dtype, |
| 543 | sb2 *fsize ); |
| 544 | sword ocinam( struct csrdef *cursor, sword pos, sb1 *tbuf, sb2 *tbufl, |
| 545 | sb1 *buf, sb2 *bufl ); |
| 546 | /* |
| 547 | ** ocidsc, ocidsr: Obtain information about a column |
| 548 | ** ocinam : get the name of a column |
| 549 | ** cursor - pointer to csrdef |
| 550 | ** pos - position in select list from [1..N] |
| 551 | ** dbsize - place to store the database size |
| 552 | ** fsize - place to store the fetched size |
| 553 | ** rcode - place to store the fetched column returned code |
| 554 | ** dtype - place to store the data type |
| 555 | ** buf - array to store the column name |
| 556 | ** bufl - place to store the column name length |
| 557 | ** dsize - maximum display size |
| 558 | ** tbuf - place to store the table name |
| 559 | ** tbufl - place to store the table name length |
| 560 | */ |
| 561 | |
| 562 | sword ocidsp ( struct csrdef *cursor, sword pos, sb4 *dbsize, sb2 *dbtype, |
| 563 | sb1 *cbuf, sb4 *cbufl, sb4 *dsize, sb2 *pre, sb2 *scl, |
| 564 | sb2 *nul ); |
| 565 | |
| 566 | sword ocidpr( ldadef *lda, oratext *object_name, size_t object_length, |
| 567 | void * reserved1, size_t reserved1_length, void * reserved2, |
| 568 | size_t reserved2_length, ub2 *overload, ub2 *position, |
| 569 | ub2 *level, oratext **argument_name, ub2 *argument_length, |
| 570 | ub2 *datatype, ub1 *default_supplied, ub1 *in_out, |
| 571 | ub4 *length, sb2 *precision, sb2 *scale, ub1 *radix, |
| 572 | ub4 *spare, ub4 *total_elements ); |
| 573 | /* |
| 574 | ** OCIDPR - User Program Interface: Describe Stored Procedure |
| 575 | ** |
| 576 | ** This routine is used to obtain information about the calling |
| 577 | ** arguments of a stored procedure. The client provides the |
| 578 | ** name of the procedure using "object_name" and "database_name" |
| 579 | ** (database name is optional). The client also supplies the |
| 580 | ** arrays for OCIDPR to return the values and indicates the |
| 581 | ** length of array via the "total_elements" parameter. Upon return |
| 582 | ** the number of elements used in the arrays is returned in the |
| 583 | ** "total_elements" parameter. If the array is too small then |
| 584 | ** an error will be returned and the contents of the return arrays |
| 585 | ** are invalid. |
| 586 | ** |
| 587 | ** |
| 588 | ** EXAMPLE : |
| 589 | ** |
| 590 | ** Client provides - |
| 591 | ** |
| 592 | ** object_name - SCOTT.ACCOUNT_UPDATE@BOSTON |
| 593 | ** total_elements - 100 |
| 594 | ** |
| 595 | ** |
| 596 | ** ACCOUNT_UPDATE is an overloaded function with specification : |
| 597 | ** |
| 598 | ** type number_table is table of number index by binary_integer; |
| 599 | ** table account (account_no number, person_id number, |
| 600 | ** balance number(7,2)) |
| 601 | ** table person (person_id number(4), person_nm varchar2(10)) |
| 602 | ** |
| 603 | ** function ACCOUNT_UPDATE (account number, |
| 604 | ** person person%rowtype, amounts number_table, |
| 605 | ** trans_date date) return accounts.balance%type; |
| 606 | ** |
| 607 | ** function ACCOUNT_UPDATE (account number, |
| 608 | ** person person%rowtype, amounts number_table, |
| 609 | ** trans_no number) return accounts.balance%type; |
| 610 | ** |
| 611 | ** |
| 612 | ** Values returned - |
| 613 | ** |
| 614 | ** overload position argument level datatype length prec scale rad |
| 615 | ** ------------------------------------------------------------------- |
| 616 | ** 0 0 0 NUMBER 22 7 2 10 |
| 617 | ** 0 1 ACCOUNT 0 NUMBER 22 0 0 0 |
| 618 | ** 0 2 PERSON 0 RECORD 0 0 0 0 |
| 619 | ** 0 2 PERSON_ID 1 NUMBER 22 4 0 10 |
| 620 | ** 0 2 PERSON_NM 1 VARCHAR2 10 0 0 0 |
| 621 | ** 0 3 AMOUNTS 0 TABLE 0 0 0 0 |
| 622 | ** 0 3 1 NUMBER 22 0 0 0 |
| 623 | ** 0 4 TRANS_NO 0 NUMBER 22 0 0 0 |
| 624 | ** |
| 625 | ** 1 0 0 NUMBER 22 7 2 10 |
| 626 | ** 1 1 ACCOUNT 0 NUMBER 22 0 0 0 |
| 627 | ** 1 2 PERSON 0 RECORD 0 0 0 0 |
| 628 | ** 1 2 PERSON_ID 1 NUMBER 22 4 0 10 |
| 629 | ** 1 2 PERSON_NM 1 VARCHAR2 10 0 0 0 |
| 630 | ** 1 3 AMOUNTS 0 TABLE 0 0 0 0 |
| 631 | ** 1 3 1 NUMBER 22 0 0 0 |
| 632 | ** 1 4 TRANS_DATE 0 NUMBER 22 0 0 0 |
| 633 | ** |
| 634 | ** |
| 635 | ** OCIDPR Argument Descriptions - |
| 636 | ** |
| 637 | ** ldadef - pointer to ldadef |
| 638 | ** object_name - object name, synonyms are also accepted and will |
| 639 | ** be translate, currently only procedure and function |
| 640 | ** names are accepted, also NLS names are accepted. |
| 641 | ** Currently, the accepted format of a name is |
| 642 | ** [[part1.]part2.]part3[@dblink] (required) |
| 643 | ** object_length - object name length (required) |
| 644 | ** reserved1 - reserved for future use |
| 645 | ** reserved1_length - reserved for future use |
| 646 | ** reserved2 - reserved for future use |
| 647 | ** reserved2_length - reserved for future use |
| 648 | ** overload - array indicating overloaded procedure # (returned) |
| 649 | ** position - array of argument positions, position 0 is a |
| 650 | ** function return argument (returned) |
| 651 | ** level - array of argument type levels, used to describe |
| 652 | ** sub-datatypes of data structures like records |
| 653 | ** and arrays (returned) |
| 654 | ** argument_name - array of argument names, only returns first |
| 655 | ** 30 characters of argument names, note storage |
| 656 | ** for 30 characters is allocated by client (returned) |
| 657 | ** argument_length - array of argument name lengths (returned) |
| 658 | ** datatype - array of oracle datatypes (returned) |
| 659 | ** default_supplied - array indicating parameter has default (returned) |
| 660 | ** 0 = no default, 1 = default supplied |
| 661 | ** in_out - array indicating if argument is IN or OUT (returned |
| 662 | ** 0 = IN param, 1 = OUT param, 2 = IN/OUT param |
| 663 | ** length - array of argument lengths (returned) |
| 664 | ** precision - array of precisions (if number type)(returned) |
| 665 | ** scale - array of scales (if number type)(returned) |
| 666 | ** radix - array of radix (if number type)(returned) |
| 667 | ** spare - array of spares. |
| 668 | ** total_elements - size of arrays supplied by client (required), |
| 669 | ** total number of elements filled (returned) |
| 670 | */ |
| 671 | |
| 672 | /*************************************/ |
| 673 | /* DEFINING */ |
| 674 | /*************************************/ |
| 675 | sword ocidfi( struct csrdef *cursor, sword pos, ub1 *buf, sword bufl, |
| 676 | sword ftype, sb2 *rc, sword scale ); |
| 677 | sword ocidfn( struct csrdef *cursor, sword pos, ub1 *buf, sword bufl, |
| 678 | sword ftype, sword scale, sb2 *indp, oratext *fmt, sword fmtl, |
| 679 | sword fmtt, ub2 *rl, ub2 *rc ); |
| 680 | sword ocidfnps( struct csrdef *cursor, ub1 opcode, sword pos, ub1 *buf, |
| 681 | sb4 bufl, sword ftype, sword scale, |
| 682 | sb2 *indp, oratext *fmt, sb4 fmtl, |
| 683 | sword fmtt, ub2 *rl, ub2 *rc, |
| 684 | sb4 pv_skip, sb4 ind_skip, sb4 len_skip, |
| 685 | sb4 rc_skip ); |
| 686 | |
| 687 | |
| 688 | /* Define a user data buffer using upidfn |
| 689 | ** cursor - pointer to csrdef |
| 690 | ** pos - position of a field or exp in the select list of a query |
| 691 | ** bfa/bfl - address and length of client-supplied storage |
| 692 | to receive data |
| 693 | ** ftype - user datatype |
| 694 | ** scale - number of fractional digits for cobol packed decimals |
| 695 | ** indp - place to store the length of the returned value. If returned |
| 696 | ** value is: |
| 697 | ** negative, the field fetched was NULL |
| 698 | ** zero , the field fetched was same length or shorter than |
| 699 | ** the buffer provided |
| 700 | ** positive, the field fetched was truncated |
| 701 | ** fmt - format string |
| 702 | ** fmtl - length of format string, if -1 strlent(fmt) used |
| 703 | ** rl - place to store column length after each fetch |
| 704 | ** rc - place to store column error code after each fetch |
| 705 | ** fmtt - fomat type |
| 706 | */ |
| 707 | |
| 708 | /********************************/ |
| 709 | /* PIECE INFORMATION GET/SET */ |
| 710 | /********************************/ |
| 711 | sword ocigetpi( struct csrdef *cursor, ub1 *piecep, |
| 712 | void **ctxpp, ub4 *iterp, ub4 *indexp ); |
| 713 | sword ocisetpi( struct csrdef *cursor, ub1 piece, |
| 714 | void *bufp, ub4 *lenp ); |
| 715 | |
| 716 | |
| 717 | /********************************/ |
| 718 | /* EXECUTE */ |
| 719 | /********************************/ |
| 720 | sword ociexe( struct csrdef *cursor ); |
| 721 | sword ociexn( struct csrdef *cursor, sword iters, sword roff ); |
| 722 | sword ociefn( struct csrdef *cursor, ub4 nrows, sword can, sword exact ); |
| 723 | /* |
| 724 | ** ociexe - execute a cursor |
| 725 | ** ociexn - execute a cursosr N times |
| 726 | ** cursor - pointer to a csrdef |
| 727 | ** iters - number of times to execute cursor |
| 728 | ** roff - offset within the bind variable array at which to begin |
| 729 | ** operations. |
| 730 | */ |
| 731 | |
| 732 | |
| 733 | /*********************************/ |
| 734 | /* FETCHING */ |
| 735 | /*********************************/ |
| 736 | sword ocifet( struct csrdef *cursor ); |
| 737 | sword ocifen( struct csrdef *cursor, sword nrows ); |
| 738 | /* ocifet - fetch the next row |
| 739 | ** ocifen - fetch n rows |
| 740 | ** cursor - pointer to csrdef |
| 741 | ** nrows - number of rows to be fetched |
| 742 | */ |
| 743 | |
| 744 | sword ocilng( struct csrdef *cursor, sword posit, ub1 *bfa, sb4 bfl, |
| 745 | sword dty, ub4 *rln, sb4 off ); |
| 746 | |
| 747 | /*********************************/ |
| 748 | /* CONVERSION */ |
| 749 | /*********************************/ |
| 750 | sword ocic32( struct csrdef *cursor ); |
| 751 | /* |
| 752 | ** Convert selected version 3 return codes to the equivalent |
| 753 | ** version 2 code. |
| 754 | ** csrdef->csrrc is set to the converted code |
| 755 | ** csrdef->csrft is set to v2 oracle statment type |
| 756 | ** csrdef->csrrpc is set to the rows processed count |
| 757 | ** csrdef->csrpeo is set to error postion |
| 758 | ** |
| 759 | ** cursor - pointer to csrdef |
| 760 | */ |
| 761 | |
| 762 | |
| 763 | sword ocir32( struct csrdef *cursor, sword retcode ); |
| 764 | /* |
| 765 | ** Convert selected version 3 return codes to the equivalent version 2 |
| 766 | ** code. |
| 767 | ** |
| 768 | ** cursor - pointer to csrdef |
| 769 | ** retcode - place to store the return code |
| 770 | */ |
| 771 | |
| 772 | |
| 773 | void ociscn( sword **arglst, char *mask_addr, sword **newlst ); |
| 774 | /* |
| 775 | ** Convert call-by-ref to call-by-value: |
| 776 | ** takes an arg list and a mask address, determines which args need |
| 777 | ** conversion to a value, and creates a new list begging at the address |
| 778 | ** of newlst. |
| 779 | ** |
| 780 | ** arglst - list of arguments |
| 781 | ** mast_addr _ mask address determines args needing conversion |
| 782 | ** newlst - new list of args |
| 783 | */ |
| 784 | |
| 785 | sword ocistf ( sword typ, sword bufl, sword rdig, oratext *fmt, |
| 786 | struct csrdef *cursor, sword *err ); |
| 787 | /* Convert a packed decimal buffer length (bytes) and scale to a format |
| 788 | ** string of the form mm.+/-nn, where mm is the number of packed |
| 789 | ** decimal digits, and nn is the scaling factor. A positive scale name |
| 790 | ** nn digits to the rights of the decimal; a negative scale means nn zeros |
| 791 | ** should be supplied to the left of the decimal. |
| 792 | ** bufl - length of the packed decimal buffer |
| 793 | ** rdig - number of fractional digits |
| 794 | ** fmt - pointer to a string holding the conversion format |
| 795 | ** cursor - pointer to csrdef |
| 796 | ** err - pointer to word storing error code |
| 797 | */ |
| 798 | |
| 799 | |
| 800 | /******************************************/ |
| 801 | /* Non-blocking operations */ |
| 802 | /******************************************/ |
| 803 | sword ocinbs( ldadef *lda ); /* set a connection to non-blocking */ |
| 804 | sword ocinbt( ldadef *lda ); /* test if connection is non-blocking */ |
| 805 | sword ocinbc( ldadef *lda ); /* clear a connection to blocking */ |
| 806 | sword ocinlo( ldadef *lda, struct hstdef *hst, oratext *conn, |
| 807 | sword connl, oratext *uid, sword uidl, |
| 808 | oratext *psw, sword pswl, sword audit ); |
| 809 | /* logon in non-blocking fashion */ |
| 810 | /* ocinlo allows an application to logon in non-blocking fashion. |
| 811 | ** lda - pointer to ldadef |
| 812 | ** hst - pointer to a 256 byte area, must be cleared to zero before call |
| 813 | ** conn - the database link (if specified @LINK in uid will be ignored) |
| 814 | ** connl - length of conn; if -1 strlen(conn) is used |
| 815 | ** uid - user id [USER[/PASSWORD][@LINK]] |
| 816 | ** uidl - length of uid, if -1 strlen(uid) is used |
| 817 | ** psw - password string; ignored if specified in uid |
| 818 | ** pswl - length of psw, if -1 strlen(psw) is used |
| 819 | ** audit - is not supported; the only permissible value is 0 |
| 820 | */ |
| 821 | |
| 822 | /***************************************************/ |
| 823 | /* Procedure Declaration for Pro*C */ |
| 824 | /***************************************************/ |
| 825 | /* Note: The following routines are used in Pro*C and have the |
| 826 | same interface as their couterpart in OCI. |
| 827 | Althought the interface follows for more details please refer |
| 828 | to the above routines */ |
| 829 | |
| 830 | /******************************************/ |
| 831 | /* initialization/logon/logof */ |
| 832 | /******************************************/ |
| 833 | sword ocipin( ub4 mode ); |
| 834 | |
| 835 | sword ologin( ldadef *lda, sb2 areacount ); |
| 836 | sword ologon( ldadef *lda, sb2 areacount ); |
| 837 | |
| 838 | /*****************************************/ |
| 839 | /* Open/Close/Parse Cursor */ |
| 840 | /*****************************************/ |
| 841 | |
| 842 | /* |
| 843 | ** ocisqd - oci delayed parse (Should be used only with deferred upi/oci) |
| 844 | ** FUNCTION: Call upidpr to delay the parse of the sql statement till the |
| 845 | ** time that a call needs to be made to the kernel (execution or |
| 846 | ** describe time ) |
| 847 | ** RETURNS: Oracle return code. |
| 848 | */ |
| 849 | sword ocisq7( struct csrdef *cursor, oratext * /* sqlstm */, sb4 sqllen, |
| 850 | sword defflg, ub4 sqlt ); |
| 851 | |
| 852 | /*****************************************/ |
| 853 | /* Bind */ |
| 854 | /*****************************************/ |
| 855 | sword obind( struct csrdef *cursor, oratext *sqlvar, sword sqlvl, |
| 856 | ub1 *progv, sword progvl, sword ftype, sword scale, |
| 857 | oratext *fmt, sword fmtl, sword fmtt ); |
| 858 | sword obindn( struct csrdef *cursor, ub2 sqlvn, ub1 *progv, sword progvl, |
| 859 | sword ftype, sword scale, oratext *fmt, sword fmtl, |
| 860 | sword fmtt ); |
| 861 | |
| 862 | /**********************************************/ |
| 863 | /* Define */ |
| 864 | /**********************************************/ |
| 865 | sword odfinn( struct csrdef *cursor, sword pos, ub1 *buf, sword bufl, |
| 866 | sword ftype, sb2 *rc, sword scale ); |
| 867 | |
| 868 | /**********************************************/ |
| 869 | /* Describe */ |
| 870 | /**********************************************/ |
| 871 | sword odsrbn( struct csrdef *cursor, sword pos, sb2 *dbsize, sb2 *dtype, |
| 872 | sb2 *fsize ); |
| 873 | |
| 874 | |
| 875 | /******************************************/ |
| 876 | /* Non-blocking operations */ |
| 877 | /******************************************/ |
| 878 | sword onblon( ldadef *lda, struct hstdef *hst, oratext *conn, |
| 879 | sword connl, oratext *uid, sword uidl, |
| 880 | oratext *psw, sword pswl, sword audit ); |
| 881 | /* logon in non-blocking fashion */ |
| 882 | sword ocignfd( ldadef *lda, void *nfdp ); /* get native fd */ |
| 883 | |
| 884 | ub2 ocigft_getFcnType( ub2 oertyp ); /* get sql function code */ |
| 885 | |
| 886 | #endif |