OCILIB (C Driver for Oracle) 3.12.1
|
00001 /* 00002 +-----------------------------------------------------------------------------------------+ 00003 | | 00004 | OCILIB - C Driver for Oracle | 00005 | | 00006 | (C Wrapper for Oracle OCI) | 00007 | | 00008 | Website : http://www.ocilib.net | 00009 | | 00010 | Copyright (c) 2007-2013 Vincent ROGIER <vince.rogier@ocilib.net> | 00011 | | 00012 +-----------------------------------------------------------------------------------------+ 00013 | | 00014 | This library is free software; you can redistribute it and/or | 00015 | modify it under the terms of the GNU Lesser General Public | 00016 | License as published by the Free Software Foundation; either | 00017 | version 2 of the License, or (at your option) any later version. | 00018 | | 00019 | This library is distributed in the hope that it will be useful, | 00020 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 00021 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 00022 | Lesser General Public License for more details. | 00023 | | 00024 | You should have received a copy of the GNU Lesser General Public | 00025 | License along with this library; if not, write to the Free | 00026 | Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 00027 | | 00028 +-----------------------------------------------------------------------------------------+ 00029 */ 00030 00031 /* --------------------------------------------------------------------------------------------- * 00032 * $Id: dirpath.c, Vincent Rogier $ 00033 * --------------------------------------------------------------------------------------------- */ 00034 00035 #include "ocilib_internal.h" 00036 00037 00038 /* ********************************************************************************************* * 00039 * PRIVATE FUNCTIONS 00040 * ********************************************************************************************* */ 00041 00042 00043 /* --------------------------------------------------------------------------------------------- * 00044 * OCI_DirPathSetArray 00045 * --------------------------------------------------------------------------------------------- */ 00046 00047 int OCI_API OCI_DirPathSetArray 00048 ( 00049 OCI_DirPath *dp, 00050 ub4 row_from 00051 ) 00052 { 00053 boolean res = TRUE; 00054 ub1 *data = NULL; 00055 ub4 size = 0; 00056 ub1 flag = 0; 00057 ub2 col = 0; 00058 ub4 row = 0; 00059 00060 /* reset the number of entries et */ 00061 00062 dp->nb_entries = 0; 00063 00064 /* set entries */ 00065 00066 for (row = row_from; (row < dp->nb_cur) && (res == TRUE); row++) 00067 { 00068 for (col = 0; (col < dp->nb_cols) && (res == TRUE); col++) 00069 { 00070 OCI_DirPathColumn *dpcol = &(dp->cols[col]); 00071 00072 /* get internal data cell */ 00073 00074 data = ((ub1 *) dpcol->data) + (size_t) (row * dpcol->bufsize); 00075 size = dpcol->lens[row]; 00076 flag = dpcol->flags[row]; 00077 00078 if (dpcol->sqlcode == SQLT_NUM) 00079 { 00080 OCINumber *num = (OCINumber *) data; 00081 00082 data = &num->OCINumberPart[1]; 00083 } 00084 00085 /* set entry value */ 00086 00087 OCI_CALL2 00088 ( 00089 res, dp->con, 00090 00091 OCIDirPathColArrayEntrySet(dp->arr, dp->con->err, (ub4) dp->nb_entries, 00092 (ub2) (col), (ub1*) data, (ub4) size, flag) 00093 ) 00094 } 00095 00096 /* increment number of item set */ 00097 00098 if (res == TRUE) 00099 { 00100 dp->nb_entries++; 00101 } 00102 } 00103 00104 return res; 00105 } 00106 00107 /* --------------------------------------------------------------------------------------------- * 00108 * OCI_DirPahArrayToStream 00109 * --------------------------------------------------------------------------------------------- */ 00110 00111 unsigned int OCI_API OCI_DirPathArrayToStream 00112 ( 00113 OCI_DirPath *dp, 00114 ub4 row_from 00115 ) 00116 { 00117 unsigned int res = OCI_DPR_COMPLETE; 00118 sword ret = OCI_SUCCESS; 00119 00120 /* convert the array to a stream */ 00121 00122 ret = OCIDirPathColArrayToStream(dp->arr, dp->ctx, dp->strm, dp->con->err, dp->nb_entries, (ub4) 0); 00123 00124 switch (ret) 00125 { 00126 case OCI_SUCCESS: 00127 { 00128 res = OCI_DPR_COMPLETE; 00129 dp->status = OCI_DPS_CONVERTED; 00130 00131 break; 00132 } 00133 case OCI_ERROR: 00134 { 00135 res = OCI_DPR_ERROR; 00136 00137 /* only raise the exception if we're not in force mode */ 00138 00139 if (dp->cvt_mode == OCI_DCM_DEFAULT) 00140 { 00141 OCI_ExceptionOCI(dp->con->err, dp->con, NULL, FALSE); 00142 } 00143 00144 break; 00145 } 00146 case OCI_CONTINUE: 00147 { 00148 dp->status = OCI_DPS_CONVERTED; 00149 res = OCI_DPR_FULL; 00150 00151 break; 00152 } 00153 case OCI_NEED_DATA: 00154 { 00155 res = OCI_DPR_PARTIAL; 00156 00157 break; 00158 } 00159 } 00160 00161 if (ret != OCI_SUCCESS) 00162 { 00163 ub4 err_row = 0; 00164 ub2 err_col = 0; 00165 ub4 size = 0; 00166 00167 size = sizeof(err_col); 00168 00169 OCIAttrGet(dp->arr, OCI_HTYPE_DIRPATH_COLUMN_ARRAY, &err_col, 00170 &size, OCI_ATTR_COL_COUNT, dp->con->err); 00171 00172 size = sizeof(err_row); 00173 00174 OCIAttrGet(dp->arr, OCI_HTYPE_DIRPATH_COLUMN_ARRAY, &err_row, 00175 &size, OCI_ATTR_ROW_COUNT, dp->con->err); 00176 00177 /* update converted rows so far */ 00178 dp->nb_converted += err_row; 00179 00180 /* record errors index on real error */ 00181 if (res == OCI_DPR_ERROR) 00182 { 00183 dp->err_rows[dp->nb_err] = row_from + err_row; 00184 dp->err_cols[dp->nb_err] = err_col; 00185 00186 dp->nb_err++; 00187 } 00188 } 00189 else 00190 { 00191 /* conversion is successful. the number of converted rows is the same 00192 as the number of row set*/ 00193 dp->nb_converted += dp->nb_entries; 00194 } 00195 00196 return res; 00197 } 00198 00199 /* --------------------------------------------------------------------------------------------- * 00200 * OCI_DirPahArrayToStream 00201 * --------------------------------------------------------------------------------------------- */ 00202 00203 unsigned int OCI_API OCI_DirPathLoadStream(OCI_DirPath *dp) 00204 { 00205 unsigned int res = OCI_DPR_COMPLETE; 00206 sword ret = OCI_SUCCESS; 00207 ub4 nb_loaded = 0; 00208 ub4 size = sizeof(nb_loaded); 00209 00210 /* load the stream */ 00211 00212 ret = OCIDirPathLoadStream(dp->ctx, dp->strm, dp->con->err); 00213 00214 switch (ret) 00215 { 00216 case OCI_SUCCESS: 00217 { 00218 res = OCI_DPR_COMPLETE; 00219 dp->status = OCI_DPS_PREPARED; 00220 00221 break; 00222 } 00223 case OCI_ERROR: 00224 { 00225 res = OCI_DPR_ERROR; 00226 00227 OCI_ExceptionOCI(dp->con->err, dp->con, NULL, FALSE); 00228 00229 break; 00230 } 00231 case OCI_NO_DATA: 00232 { 00233 res = OCI_DPR_EMPTY; 00234 00235 break; 00236 } 00237 case OCI_NEED_DATA: 00238 { 00239 res = OCI_DPR_PARTIAL; 00240 00241 break; 00242 } 00243 } 00244 00245 /* retrieve the number of rows loaded so far */ 00246 00247 OCIAttrGet(dp->strm, OCI_HTYPE_DIRPATH_STREAM, &nb_loaded, 00248 &size, OCI_ATTR_ROW_COUNT, dp->con->err); 00249 00250 dp->nb_loaded += nb_loaded; 00251 dp->nb_processed += nb_loaded; 00252 00253 /* On failurte, record errors rows */ 00254 00255 if (ret != OCI_SUCCESS) 00256 { 00257 dp->err_rows[dp->nb_err] = (dp->nb_err > 0) ? (dp->err_rows[dp->nb_err-1] + nb_loaded + 1) : dp->nb_loaded; 00258 dp->err_cols[dp->nb_err] = 0; 00259 dp->nb_err++; 00260 } 00261 00262 return res; 00263 } 00264 00265 /* ********************************************************************************************* * 00266 * PUBLIC FUNCTIONS 00267 * ********************************************************************************************* */ 00268 00269 /* --------------------------------------------------------------------------------------------- * 00270 * OCI_DirPathCreate 00271 * --------------------------------------------------------------------------------------------- */ 00272 00273 OCI_DirPath * OCI_API OCI_DirPathCreate 00274 ( 00275 OCI_TypeInfo *typinf, 00276 const mtext *partition, 00277 unsigned int nb_cols, 00278 unsigned int nb_rows 00279 ) 00280 { 00281 OCI_DirPath *dp = NULL; 00282 boolean res = TRUE; 00283 00284 OCI_CHECK_PTR(OCI_IPC_TYPE_INFO, typinf, NULL); 00285 00286 OCI_CHECK_COMPAT(typinf->con, typinf->type != OCI_TIF_TYPE, NULL); 00287 OCI_CHECK_BOUND(typinf->con, nb_cols, 1, typinf->nb_cols, NULL); 00288 00289 /* allocate direct path structure */ 00290 00291 dp = (OCI_DirPath *) OCI_MemAlloc(OCI_IPC_DIRPATH, sizeof(*dp), (size_t) 1, TRUE); 00292 00293 if (dp != NULL) 00294 { 00295 void *ostr = NULL; 00296 int osize = -1; 00297 00298 dp->con = typinf->con; 00299 dp->status = OCI_DPS_NOT_PREPARED; 00300 dp->cvt_mode = OCI_DCM_DEFAULT; 00301 dp->res_conv = OCI_DPR_EMPTY; 00302 dp->res_load = OCI_DPR_EMPTY; 00303 dp->typinf = typinf; 00304 dp->nb_rows = (ub2) nb_rows; 00305 dp->nb_cols = (ub2) nb_cols; 00306 dp->nb_cur = (ub2) dp->nb_rows; 00307 dp->nb_entries = 0; 00308 dp->nb_err = 0; 00309 dp->idx_err_col = 0; 00310 dp->idx_err_row = 0; 00311 dp->nb_converted = 0; 00312 dp->nb_loaded = 0; 00313 dp->nb_converted = 0; 00314 00315 /* allocates direct context handle */ 00316 00317 if (res == TRUE) 00318 { 00319 res = (OCI_SUCCESS == OCI_HandleAlloc((dvoid *) dp->con->env, 00320 (dvoid **) (void *) &dp->ctx, 00321 (ub4) OCI_HTYPE_DIRPATH_CTX, 00322 (size_t) 0, (dvoid **) NULL)); 00323 } 00324 00325 /* set table name attribute */ 00326 00327 if (res == TRUE) 00328 { 00329 osize = -1; 00330 ostr = OCI_GetInputMetaString(dp->typinf->name, &osize); 00331 00332 OCI_CALL2 00333 ( 00334 res, dp->con, 00335 00336 OCIAttrSet((dvoid *) dp->ctx, (ub4) OCI_HTYPE_DIRPATH_CTX, 00337 (dvoid *) ostr, (ub4) osize, (ub4) OCI_ATTR_NAME, dp->con->err) 00338 ) 00339 00340 OCI_ReleaseMetaString(ostr); 00341 } 00342 00343 /* set schema name attribute */ 00344 00345 if ((res == TRUE) && (dp->typinf->schema != NULL) && (dp->typinf->schema[0] != 0)) 00346 { 00347 osize = -1; 00348 ostr = OCI_GetInputMetaString(dp->typinf->schema, &osize); 00349 00350 OCI_CALL2 00351 ( 00352 res, dp->con, 00353 00354 OCIAttrSet((dvoid *) dp->ctx, (ub4) OCI_HTYPE_DIRPATH_CTX, 00355 (dvoid *) ostr, (ub4) osize, (ub4) OCI_ATTR_SCHEMA_NAME, dp->con->err) 00356 ) 00357 00358 OCI_ReleaseMetaString(ostr); 00359 } 00360 00361 /* set partition name attribute */ 00362 00363 if ((res == TRUE) && (partition != NULL) && (partition[0] != 0)) 00364 { 00365 osize = -1; 00366 ostr = OCI_GetInputMetaString(partition, &osize); 00367 00368 OCI_CALL2 00369 ( 00370 res, dp->con, 00371 00372 OCIAttrSet((dvoid *) dp->ctx, (ub4) OCI_HTYPE_DIRPATH_CTX, 00373 (dvoid *) ostr, (ub4) osize, (ub4) OCI_ATTR_SUB_NAME, dp->con->err) 00374 ) 00375 00376 OCI_ReleaseMetaString(ostr); 00377 } 00378 00379 if (OCILib.version_runtime >= OCI_9_0) 00380 { 00381 ub4 num_rows = dp->nb_rows; 00382 00383 /* set array size attribute */ 00384 00385 OCI_CALL2 00386 ( 00387 res, dp->con, 00388 00389 OCIAttrSet((dvoid *) dp->ctx, (ub4) OCI_HTYPE_DIRPATH_CTX, 00390 (dvoid *) &num_rows, (ub4) sizeof(num_rows), 00391 (ub4) OCI_ATTR_NUM_ROWS, dp->con->err) 00392 ) 00393 } 00394 00395 /* set columns count attribute */ 00396 00397 OCI_CALL2 00398 ( 00399 res, dp->con, 00400 00401 OCIAttrSet((dvoid *) dp->ctx, (ub4) OCI_HTYPE_DIRPATH_CTX, 00402 (dvoid *) &dp->nb_cols, (ub4) sizeof(dp->nb_cols), 00403 (ub4) OCI_ATTR_NUM_COLS, dp->con->err) 00404 ) 00405 00406 /* allocating the column array */ 00407 00408 if (res == TRUE) 00409 { 00410 dp->cols = (void *) OCI_MemAlloc(OCI_IPC_DP_COL_ARRAY, sizeof(OCI_DirPathColumn), 00411 (size_t) dp->nb_cols, TRUE); 00412 00413 res = (dp->cols != NULL); 00414 } 00415 } 00416 else 00417 { 00418 res = FALSE; 00419 } 00420 00421 /* handle errors */ 00422 00423 if (res == FALSE) 00424 { 00425 OCI_DirPathFree(dp); 00426 dp = NULL; 00427 } 00428 00429 OCI_RESULT(res); 00430 00431 return dp; 00432 } 00433 00434 /* --------------------------------------------------------------------------------------------- * 00435 * OCI_DirPathFree 00436 * --------------------------------------------------------------------------------------------- */ 00437 00438 boolean OCI_API OCI_DirPathFree 00439 ( 00440 OCI_DirPath *dp 00441 ) 00442 { 00443 ub2 i; 00444 00445 OCI_CHECK_PTR(OCI_IPC_DIRPATH, dp, FALSE); 00446 00447 for (i = 0; i < dp->nb_cols; i++) 00448 { 00449 OCI_FREE(dp->cols[i].data); 00450 OCI_FREE(dp->cols[i].lens); 00451 OCI_FREE(dp->cols[i].flags); 00452 OCI_FREE(dp->cols[i].format); 00453 } 00454 00455 OCI_FREE(dp->cols); 00456 OCI_FREE(dp->err_cols); 00457 OCI_FREE(dp->err_rows); 00458 00459 OCI_HandleFree(dp->strm, OCI_HTYPE_DIRPATH_STREAM); 00460 OCI_HandleFree(dp->arr, OCI_HTYPE_DIRPATH_COLUMN_ARRAY); 00461 OCI_HandleFree(dp->ctx, OCI_HTYPE_DIRPATH_CTX); 00462 00463 OCI_FREE(dp); 00464 00465 OCI_RESULT(TRUE); 00466 00467 return TRUE; 00468 } 00469 00470 /* --------------------------------------------------------------------------------------------- * 00471 * OCI_DirPathSetColumn 00472 * --------------------------------------------------------------------------------------------- */ 00473 00474 boolean OCI_API OCI_DirPathSetColumn 00475 ( 00476 OCI_DirPath *dp, 00477 unsigned int index, 00478 const mtext *name, 00479 unsigned int maxsize, 00480 const mtext *format 00481 ) 00482 { 00483 OCI_DirPathColumn *dpcol = NULL; 00484 OCI_Column *col = NULL; 00485 OCIParam *hattr = NULL; 00486 OCIParam *hlist = NULL; 00487 void *ostr = NULL; 00488 int osize = -1; 00489 boolean res = TRUE; 00490 ub2 i; 00491 00492 OCI_CHECK_PTR(OCI_IPC_DIRPATH, dp, FALSE); 00493 OCI_CHECK_DIRPATH_STATUS(dp, OCI_DPS_NOT_PREPARED, FALSE); 00494 OCI_CHECK_PTR(OCI_IPC_STRING, name, FALSE); 00495 OCI_CHECK_BOUND(dp->con, index, 1, dp->nb_cols, FALSE); 00496 00497 /* check if column exists */ 00498 00499 for (i = 0; i < dp->typinf->nb_cols; i++) 00500 { 00501 if (mtscasecmp(name, dp->typinf->cols[i].name) == 0) 00502 { 00503 break; 00504 } 00505 } 00506 00507 /* check if column was found */ 00508 00509 if (i >= dp->typinf->nb_cols) 00510 { 00511 OCI_ExceptionDirPathColNotFound(dp, name, dp->typinf->name); 00512 00513 res = FALSE; 00514 } 00515 00516 /* set column information */ 00517 00518 if (res == TRUE) 00519 { 00520 col = &dp->typinf->cols[i]; 00521 dpcol = &dp->cols[index-1]; 00522 00523 /* default column attributes */ 00524 00525 dpcol->maxsize = (ub2) maxsize; 00526 dpcol->bufsize = (ub2) maxsize + 1; 00527 dpcol->sqlcode = SQLT_CHR; 00528 dpcol->type = OCI_DDT_TEXT; 00529 dpcol->index = i; 00530 dpcol->format_size = 0; 00531 00532 switch (col->type) 00533 { 00534 case OCI_CDT_TEXT: 00535 { 00536 dpcol->maxsize *= sizeof(dtext); 00537 dpcol->bufsize *= sizeof(dtext); 00538 00539 if (OCILib.nls_utf8 == TRUE) 00540 { 00541 dpcol->bufsize *= UTF8_BYTES_PER_CHAR; 00542 } 00543 00544 break; 00545 } 00546 case OCI_CDT_NUMERIC: 00547 { 00548 if ((format != NULL) && (format[0] != 0)) 00549 { 00550 dpcol->format = mtsdup(format); 00551 dpcol->format_size = (ub4) mtslen(format); 00552 dpcol->type = OCI_DDT_NUMBER; 00553 dpcol->sqlcode = SQLT_NUM; 00554 dpcol->bufsize = sizeof(OCINumber); 00555 dpcol->maxsize = sizeof(OCINumber); 00556 } 00557 else 00558 { 00559 dpcol->type = OCI_DDT_OTHERS; 00560 } 00561 00562 break; 00563 } 00564 case OCI_CDT_DATETIME: 00565 case OCI_CDT_TIMESTAMP: 00566 case OCI_CDT_INTERVAL: 00567 { 00568 dpcol->type = OCI_DDT_OTHERS; 00569 00570 if ((format != NULL) && (format[0] != 0)) 00571 { 00572 dpcol->format = mtsdup(format); 00573 dpcol->format_size = (ub4) mtslen(format); 00574 dpcol->maxsize = (ub2) dpcol->format_size; 00575 dpcol->bufsize *= sizeof(dtext); 00576 } 00577 00578 break; 00579 } 00580 case OCI_CDT_LOB: 00581 { 00582 if (col->subtype == OCI_BLOB) 00583 { 00584 dpcol->type = OCI_DDT_BINARY; 00585 dpcol->sqlcode = SQLT_BIN; 00586 } 00587 00588 break; 00589 } 00590 case OCI_CDT_LONG: 00591 { 00592 if (col->subtype == OCI_BLONG) 00593 { 00594 dpcol->type = OCI_DDT_BINARY; 00595 dpcol->sqlcode = SQLT_BIN; 00596 } 00597 00598 break; 00599 } 00600 case OCI_CDT_RAW: 00601 { 00602 dpcol->type = OCI_DDT_BINARY; 00603 dpcol->sqlcode = SQLT_BIN; 00604 00605 break; 00606 } 00607 default: 00608 { 00609 res = FALSE; 00610 OCI_ExceptionDatatypeNotSupported(dp->con, NULL, col->ocode); 00611 00612 break; 00613 } 00614 } 00615 } 00616 00617 /* if supported datatype, set direct path column attributes */ 00618 00619 if (res == TRUE) 00620 { 00621 /* get column parameter list handle */ 00622 00623 OCI_CALL2 00624 ( 00625 res, dp->con, 00626 00627 OCIAttrGet(dp->ctx, OCI_HTYPE_DIRPATH_CTX, &hlist, NULL, OCI_ATTR_LIST_COLUMNS, dp->con->err) 00628 ) 00629 00630 /* get colum attribute handle */ 00631 00632 OCI_CALL2 00633 ( 00634 res, dp->con, 00635 00636 OCIParamGet((dvoid *) hlist, OCI_DTYPE_PARAM, dp->con->err, 00637 (dvoid** ) (dvoid *) &hattr, (ub4) index) 00638 ) 00639 00640 /* set column name */ 00641 00642 if (res == TRUE) 00643 { 00644 osize = -1; 00645 ostr = OCI_GetInputMetaString(name, &osize); 00646 00647 OCI_CALL2 00648 ( 00649 res, dp->con, 00650 00651 OCIAttrSet((dvoid *) hattr, (ub4) OCI_DTYPE_PARAM, 00652 (dvoid *) ostr, (ub4) osize, (ub4) OCI_ATTR_NAME, dp->con->err) 00653 ) 00654 00655 OCI_ReleaseMetaString(ostr); 00656 } 00657 00658 /* set column type */ 00659 00660 OCI_CALL2 00661 ( 00662 res, dp->con, 00663 00664 OCIAttrSet((dvoid *) hattr, (ub4) OCI_DTYPE_PARAM, 00665 (dvoid *) &dpcol->sqlcode, sizeof(dpcol->sqlcode), 00666 (ub4) OCI_ATTR_DATA_TYPE, dp->con->err) 00667 ) 00668 00669 /* set column size */ 00670 00671 OCI_CALL2 00672 ( 00673 res, dp->con, 00674 00675 OCIAttrSet((dvoid *) hattr, (ub4) OCI_DTYPE_PARAM, 00676 (dvoid *) &dpcol->maxsize, sizeof(dpcol->maxsize), 00677 (ub4) OCI_ATTR_DATA_SIZE, dp->con->err) 00678 ) 00679 00680 /* set column precision */ 00681 00682 if (col->prec != 0) 00683 { 00684 OCI_CALL2 00685 ( 00686 res, dp->con, 00687 00688 OCIAttrSet((dvoid *) hattr, (ub4) OCI_DTYPE_PARAM, 00689 (dvoid *) &col->prec, sizeof(col->prec), 00690 (ub4) OCI_ATTR_PRECISION, dp->con->err) 00691 ) 00692 } 00693 00694 /* set column scale */ 00695 00696 if (col->scale != 0) 00697 { 00698 OCI_CALL2 00699 ( 00700 res, dp->con, 00701 00702 OCIAttrSet((dvoid *) hattr, (ub4) OCI_DTYPE_PARAM, 00703 (dvoid *) &col->scale, sizeof(col->scale), 00704 (ub4) OCI_ATTR_SCALE, dp->con->err) 00705 ) 00706 } 00707 00708 /* set column date/time format attribute */ 00709 00710 if ((res == TRUE) && (dpcol->type != OCI_DDT_NUMBER) && 00711 (dpcol->format != NULL) && (dpcol->format[0] != 0)) 00712 { 00713 osize = -1; 00714 ostr = OCI_GetInputMetaString(dpcol->format, &osize); 00715 00716 OCI_CALL2 00717 ( 00718 res, dp->con, 00719 00720 OCIAttrSet((dvoid *) hattr, (ub4) OCI_DTYPE_PARAM, 00721 (dvoid *) ostr, (ub4) osize, 00722 (ub4) OCI_ATTR_DATEFORMAT, dp->con->err) 00723 ) 00724 00725 OCI_ReleaseMetaString(ostr); 00726 } 00727 00728 #ifdef OCI_CHARSET_WIDE 00729 00730 /* setup Unicode mode for Unicode user data */ 00731 00732 if (dpcol->type == OCI_DDT_TEXT) 00733 { 00734 ub2 csid = OCI_UTF16ID; 00735 00736 OCI_CALL2 00737 ( 00738 res, dp->con, 00739 00740 OCIAttrSet((dvoid *) hattr, (ub4) OCI_DTYPE_PARAM, 00741 (dvoid *) &csid, (ub4) sizeof(csid), 00742 (ub4) OCI_ATTR_CHARSET_ID, dp->con->err) 00743 ) 00744 } 00745 00746 #endif 00747 00748 /* free param handle */ 00749 00750 OCIDescriptorFree(hattr, OCI_DTYPE_PARAM); 00751 } 00752 00753 OCI_RESULT(res); 00754 00755 return res; 00756 } 00757 00758 /* --------------------------------------------------------------------------------------------- * 00759 * OCI_DirPathPrepare 00760 * --------------------------------------------------------------------------------------------- */ 00761 00762 boolean OCI_API OCI_DirPathPrepare 00763 ( 00764 OCI_DirPath *dp 00765 ) 00766 { 00767 boolean res = TRUE; 00768 00769 OCI_CHECK_PTR(OCI_IPC_DIRPATH, dp, FALSE); 00770 OCI_CHECK_DIRPATH_STATUS(dp, OCI_DPS_NOT_PREPARED, FALSE); 00771 00772 /* prepare direct path operation */ 00773 00774 OCI_CALL2 00775 ( 00776 res, dp->con, 00777 00778 OCIDirPathPrepare(dp->ctx, dp->con->cxt, dp->con->err) 00779 ) 00780 00781 /* allocate column array handle */ 00782 00783 if (res == TRUE) 00784 { 00785 res = (OCI_SUCCESS == OCI_HandleAlloc((dvoid *) dp->ctx, 00786 (dvoid **) (void *) &dp->arr, 00787 (ub4) OCI_HTYPE_DIRPATH_COLUMN_ARRAY, 00788 (size_t) 0, (dvoid **) NULL)); 00789 } 00790 00791 /* allocate stream handle */ 00792 00793 if (res == TRUE) 00794 { 00795 res = (OCI_SUCCESS == OCI_HandleAlloc((dvoid *) dp->ctx, 00796 (dvoid **) (void *) &dp->strm, 00797 (ub4) OCI_HTYPE_DIRPATH_STREAM, 00798 (size_t) 0, (dvoid **) NULL)); 00799 } 00800 00801 /* check the number of rows allocated */ 00802 00803 if (res == TRUE) 00804 { 00805 ub4 num_rows = 0; 00806 ub4 size = sizeof(num_rows); 00807 00808 OCI_CALL2 00809 ( 00810 res, dp->con, 00811 00812 OCIAttrGet(dp->arr, OCI_HTYPE_DIRPATH_COLUMN_ARRAY, &num_rows, 00813 &size, OCI_ATTR_NUM_ROWS, dp->con->err) 00814 ) 00815 00816 dp->nb_cur = (ub2) num_rows; 00817 dp->nb_rows = (ub2) num_rows; 00818 } 00819 00820 /* allocate array of errs rows */ 00821 00822 if (res == TRUE) 00823 { 00824 dp->err_rows = (ub4 *) OCI_MemAlloc(OCI_IPC_BUFF_ARRAY, sizeof(*dp->err_rows), 00825 (size_t) dp->nb_cur, TRUE); 00826 00827 res = (dp->err_rows != NULL); 00828 } 00829 00830 /* allocate array of errs cols */ 00831 00832 if (res == TRUE) 00833 { 00834 dp->err_cols = (ub2 *) OCI_MemAlloc(OCI_IPC_BUFF_ARRAY, sizeof(*dp->err_cols), 00835 (size_t) dp->nb_cur, TRUE); 00836 00837 res = (dp->err_cols != NULL); 00838 } 00839 00840 /* now, we need to allocate internal buffers */ 00841 00842 if (res == TRUE) 00843 { 00844 ub2 i; 00845 00846 for (i = 0; i < dp->nb_cols; i++) 00847 { 00848 OCI_DirPathColumn *col = &dp->cols[i]; 00849 00850 /* data buffers */ 00851 00852 col->data = (ub1 *) OCI_MemAlloc(OCI_IPC_BUFF_ARRAY, 00853 (size_t) col->bufsize, 00854 (size_t) dp->nb_cur, TRUE); 00855 00856 if (col->data == NULL) 00857 { 00858 res = FALSE; 00859 break; 00860 } 00861 00862 /* data sizes */ 00863 00864 col->lens = (ub4 *) OCI_MemAlloc(OCI_IPC_BUFF_ARRAY, sizeof(ub4), 00865 (size_t) dp->nb_cur, TRUE); 00866 00867 if (col->lens == NULL) 00868 { 00869 res = FALSE; 00870 break; 00871 } 00872 00873 /* data flags */ 00874 00875 col->flags = (ub1 *) OCI_MemAlloc(OCI_IPC_BUFF_ARRAY, sizeof(ub1), 00876 (size_t) dp->nb_cur, TRUE); 00877 00878 if (col->flags == NULL) 00879 { 00880 res = FALSE; 00881 break; 00882 } 00883 } 00884 } 00885 00886 if (res == TRUE) 00887 { 00888 dp->status = OCI_DPS_PREPARED; 00889 } 00890 00891 OCI_RESULT(res); 00892 00893 return res; 00894 } 00895 00896 /* --------------------------------------------------------------------------------------------- * 00897 * OCI_DirPathSetEntry 00898 * --------------------------------------------------------------------------------------------- */ 00899 00900 boolean OCI_API OCI_DirPathSetEntry 00901 ( 00902 OCI_DirPath *dp, 00903 unsigned int row, 00904 unsigned int index, 00905 void *value, 00906 unsigned int size, 00907 boolean complete 00908 ) 00909 { 00910 boolean res = TRUE; 00911 OCI_DirPathColumn *dpcol = NULL; 00912 00913 ub1 *data; 00914 ub1 flag; 00915 00916 OCI_CHECK_PTR(OCI_IPC_DIRPATH, dp, FALSE); 00917 00918 OCI_CHECK_DIRPATH_STATUS(dp, OCI_DPS_PREPARED, FALSE); 00919 OCI_CHECK_BOUND(dp->con, index, 1, dp->nb_cols, FALSE); 00920 OCI_CHECK_BOUND(dp->con, row, 1, dp->nb_cur, FALSE); 00921 00922 dpcol = &dp->cols[index-1]; 00923 00924 if (dpcol != NULL) 00925 { 00926 /* check size */ 00927 00928 if (size > dpcol->maxsize) 00929 { 00930 size = (unsigned int) dpcol->maxsize; 00931 } 00932 00933 /* setup column flag */ 00934 00935 if (value == NULL) 00936 { 00937 flag = OCI_DIRPATH_COL_NULL; 00938 size = 0; 00939 } 00940 else if (complete == TRUE) 00941 { 00942 flag = OCI_DIRPATH_COL_COMPLETE; 00943 } 00944 else 00945 { 00946 flag = OCI_DIRPATH_COL_PARTIAL; 00947 } 00948 00949 /* Process only if data is not null */ 00950 00951 if (value != NULL) 00952 { 00953 /* for character based column, parameter size was the number of characters */ 00954 00955 if (dpcol->sqlcode == SQLT_CHR) 00956 { 00957 size *= (unsigned int) sizeof(dtext); 00958 } 00959 00960 /* get internal data cell */ 00961 00962 data = ((ub1 *) dpcol->data) + (size_t) ((row-1) * dpcol->bufsize); 00963 00964 #if defined(OCI_CHECK_DATASTRINGS) 00965 00966 /* we weed to pack the buffer if wchar_t is 4 bytes */ 00967 00968 if (dpcol->type == OCI_DDT_TEXT) 00969 { 00970 int osize = -1; 00971 00972 OCI_GetOutputString(value, data, &size, sizeof(dtext), sizeof(odtext)); 00973 } 00974 else 00975 00976 #endif 00977 00978 #if defined(OCI_USERDATA_WIDE) 00979 00980 /* input Unicode numeric values causes oracle conversion error. 00981 so, let's convert them to ansi */ 00982 00983 if (dpcol->type == OCI_DDT_OTHERS) 00984 { 00985 size = (unsigned int) wcstombs((char *) data, value, dpcol->bufsize - 1); 00986 } 00987 else 00988 00989 #endif 00990 00991 /* if a format was provided for a numeric column, we convert the input 00992 buffer to a OCINumber */ 00993 00994 if (dpcol->type == OCI_DDT_NUMBER) 00995 { 00996 OCINumber *num = (OCINumber *) data; 00997 00998 res = OCI_NumberFromString(dp->con, num, sizeof(*num), OCI_NUM_NUMBER, SQLT_NUM, (dtext *) value, dpcol->format); 00999 01000 if (res == TRUE) 01001 { 01002 size = (unsigned int) num->OCINumberPart[0]; 01003 } 01004 } 01005 else 01006 { 01007 01008 #if defined(OCI_CHARSET_MIXED) 01009 01010 /* with mixed charset builds, OCIDirPrepare() causes a segfault if the 01011 attribute OCI_ATTR_CHARSET_ID has been set with OCI_UTF16. 01012 In the OCILIB direct path implementation, the code is the same for 01013 Unicode and mixed charset. This only difference is the 01014 environment mode set of UTF16... 01015 So let's convert the data back to ANSI until Oracle corrects this bug */ 01016 01017 if (dpcol->type == OCI_DDT_TEXT) 01018 { 01019 size = (unsigned int) wcstombs((char *) data, value, dpcol->bufsize - 1); 01020 } 01021 else 01022 01023 #endif 01024 01025 { 01026 memcpy(data, value, (size_t) size); 01027 } 01028 } 01029 } 01030 01031 dpcol->lens[row-1] = size; 01032 dpcol->flags[row-1] = flag; 01033 } 01034 else 01035 { 01036 res = FALSE; 01037 } 01038 01039 OCI_RESULT(res); 01040 01041 return res; 01042 } 01043 01044 /* --------------------------------------------------------------------------------------------- * 01045 * OCI_DirPathReset 01046 * --------------------------------------------------------------------------------------------- */ 01047 01048 boolean OCI_API OCI_DirPathReset 01049 ( 01050 OCI_DirPath *dp 01051 ) 01052 { 01053 boolean res = TRUE; 01054 01055 OCI_CHECK_PTR(OCI_IPC_DIRPATH, dp, FALSE); 01056 01057 /* reset conversion and loading variables */ 01058 01059 dp->nb_processed = 0; 01060 dp->nb_converted = 0; 01061 dp->nb_err = 0; 01062 dp->idx_err_row = 0; 01063 dp->idx_err_col = 0; 01064 01065 /* reset array */ 01066 01067 OCI_CALL2 01068 ( 01069 res, dp->con, 01070 01071 OCIDirPathColArrayReset(dp->arr, dp->con->err) 01072 ) 01073 01074 /* reset stream */ 01075 01076 OCI_CALL2 01077 ( 01078 res, dp->con, 01079 01080 OCIDirPathStreamReset(dp->strm, dp->con->err) 01081 ) 01082 01083 OCI_RESULT(res); 01084 01085 return res; 01086 } 01087 01088 /* --------------------------------------------------------------------------------------------- * 01089 * OCI_DirPathConvert 01090 * --------------------------------------------------------------------------------------------- */ 01091 01092 unsigned int OCI_API OCI_DirPathConvert 01093 ( 01094 OCI_DirPath *dp 01095 ) 01096 { 01097 unsigned int res = TRUE; 01098 ub4 row_from = 0; 01099 01100 OCI_CHECK_PTR(OCI_IPC_DIRPATH, dp, OCI_DPR_ERROR); 01101 01102 OCI_CHECK_DIRPATH_STATUS(dp, OCI_DPS_PREPARED, OCI_DPR_ERROR); 01103 01104 /* reset the number of processed rows */ 01105 01106 dp->nb_processed = 0; 01107 01108 /* in case of previous error in default mode or if the stream is full, 01109 let's start again from the last faulted row */ 01110 01111 if ((dp->cvt_mode == OCI_DCM_DEFAULT || dp->res_conv == OCI_DPR_FULL) && (dp->nb_err > 0)) 01112 { 01113 row_from = dp->err_rows[dp->nb_err - 1]; 01114 } 01115 01116 /* reset the stream if it is full */ 01117 01118 if (dp->res_conv == OCI_DPR_FULL) 01119 { 01120 OCI_CALL2 01121 ( 01122 res, dp->con, 01123 01124 OCIDirPathStreamReset(dp->strm, dp->con->err) 01125 ) 01126 } 01127 01128 /* reset conversion status back to default error value */ 01129 01130 dp->res_conv = OCI_DPR_ERROR; 01131 01132 /* set array values */ 01133 01134 if (res == TRUE && OCI_DirPathSetArray(dp, row_from) == TRUE) 01135 { 01136 /* try to convert values from array into stream */ 01137 01138 dp->res_conv = OCI_DirPathArrayToStream(dp, row_from); 01139 01140 /* in case of conversion error, continue conversion in force mode 01141 other return from conversion */ 01142 01143 if (dp->cvt_mode == OCI_DCM_FORCE && dp->res_conv == OCI_DPR_ERROR) 01144 { 01145 /* perfom conversion until all non erred rows are converted */ 01146 01147 while ((dp->res_conv == OCI_DPR_ERROR) && (dp->nb_err <= dp->nb_cur) && (res == TRUE)) 01148 { 01149 /* start from the row that follows the last erred row */ 01150 01151 row_from = dp->err_rows[dp->nb_err - 1] + 1; 01152 01153 /* set values again */ 01154 01155 res = OCI_DirPathSetArray(dp, row_from); 01156 01157 if (res == TRUE) 01158 { 01159 /* perform conversion again */ 01160 01161 dp->res_conv = OCI_DirPathArrayToStream(dp, row_from); 01162 } 01163 } 01164 } 01165 } 01166 01167 dp->nb_processed = dp->nb_converted; 01168 01169 OCI_RESULT(dp->res_conv == OCI_DPR_COMPLETE); 01170 01171 return dp->res_conv; 01172 } 01173 01174 /* --------------------------------------------------------------------------------------------- * 01175 * OCI_DirPathLoad 01176 * --------------------------------------------------------------------------------------------- */ 01177 01178 unsigned int OCI_API OCI_DirPathLoad 01179 ( 01180 OCI_DirPath *dp 01181 ) 01182 { 01183 OCI_CHECK_PTR(OCI_IPC_DIRPATH, dp, OCI_DPR_ERROR); 01184 01185 OCI_CHECK_DIRPATH_STATUS(dp, OCI_DPS_CONVERTED, OCI_DPR_ERROR); 01186 01187 /* reset the number of processed rows */ 01188 01189 dp->nb_processed = 0; 01190 01191 /* reset errors variables as OCI_DirPathLoad() is not reentrant */ 01192 01193 dp->nb_err = 0; 01194 dp->idx_err_col = 0; 01195 dp->idx_err_row = 0; 01196 dp->res_load = OCI_DPR_COMPLETE; 01197 01198 /* load the stream */ 01199 01200 dp->res_load = OCI_DirPathLoadStream(dp); 01201 01202 /* continue to load the stream while it returns an error */ 01203 01204 while (dp->res_load == OCI_DPR_ERROR) 01205 { 01206 dp->res_load = OCI_DirPathLoadStream(dp); 01207 } 01208 01209 OCI_RESULT(dp->res_load == OCI_DPR_COMPLETE); 01210 01211 return dp->res_load; 01212 } 01213 01214 /* --------------------------------------------------------------------------------------------- * 01215 * OCI_DirPathFinish 01216 * --------------------------------------------------------------------------------------------- */ 01217 01218 boolean OCI_API OCI_DirPathFinish 01219 ( 01220 OCI_DirPath *dp 01221 ) 01222 { 01223 boolean res = TRUE; 01224 01225 OCI_CHECK_PTR(OCI_IPC_DIRPATH, dp, FALSE); 01226 01227 OCI_CHECK_DIRPATH_STATUS(dp, OCI_DPS_PREPARED, FALSE); 01228 01229 OCI_CALL2 01230 ( 01231 res, dp->con, 01232 01233 OCIDirPathFinish(dp->ctx, dp->con->err) 01234 ) 01235 01236 if (res == TRUE) 01237 { 01238 dp->status = OCI_DPS_TERMINATED; 01239 } 01240 01241 OCI_RESULT(res); 01242 01243 return res; 01244 } 01245 01246 /* --------------------------------------------------------------------------------------------- * 01247 * OCI_DirPathAbort 01248 * --------------------------------------------------------------------------------------------- */ 01249 01250 boolean OCI_API OCI_DirPathAbort 01251 ( 01252 OCI_DirPath *dp 01253 ) 01254 { 01255 boolean res = TRUE; 01256 01257 OCI_CHECK_PTR(OCI_IPC_DIRPATH, dp, FALSE); 01258 01259 OCI_CHECK_DIRPATH_STATUS(dp, OCI_DPS_PREPARED, FALSE); 01260 01261 OCI_CALL2 01262 ( 01263 res, dp->con, 01264 01265 OCIDirPathAbort(dp->ctx, dp->con->err) 01266 ) 01267 01268 if (res == TRUE) 01269 { 01270 dp->status = OCI_DPS_TERMINATED; 01271 } 01272 01273 OCI_RESULT(res); 01274 01275 return res; 01276 } 01277 01278 /* --------------------------------------------------------------------------------------------- * 01279 * OCI_DirPathSave 01280 * --------------------------------------------------------------------------------------------- */ 01281 01282 boolean OCI_API OCI_DirPathSave 01283 ( 01284 OCI_DirPath *dp 01285 ) 01286 { 01287 boolean res = TRUE; 01288 01289 OCI_CHECK_PTR(OCI_IPC_DIRPATH, dp, FALSE); 01290 01291 OCI_CHECK_DIRPATH_STATUS(dp, OCI_DPS_PREPARED, FALSE); 01292 01293 OCI_CALL2 01294 ( 01295 res, dp->con, 01296 01297 OCIDirPathDataSave(dp->ctx, dp->con->err, OCI_DIRPATH_DATASAVE_SAVEONLY) 01298 ) 01299 01300 OCI_RESULT(res); 01301 01302 return res; 01303 } 01304 01305 /* --------------------------------------------------------------------------------------------- * 01306 * OCI_DirPathFlushRow 01307 * --------------------------------------------------------------------------------------------- */ 01308 01309 boolean OCI_API OCI_DirPathFlushRow 01310 ( 01311 OCI_DirPath *dp 01312 ) 01313 { 01314 boolean res = TRUE; 01315 01316 OCI_CHECK_PTR(OCI_IPC_DIRPATH, dp, FALSE); 01317 01318 OCI_CHECK_DIRPATH_STATUS(dp, OCI_DPS_PREPARED, FALSE); 01319 01320 OCI_CALL2 01321 ( 01322 res, dp->con, 01323 01324 OCIDirPathFlushRow(dp->ctx, dp->con->err) 01325 ) 01326 01327 OCI_RESULT(res); 01328 01329 return res; 01330 } 01331 01332 /* --------------------------------------------------------------------------------------------- * 01333 * OCI_DirPathSetCurrentRows 01334 * --------------------------------------------------------------------------------------------- */ 01335 01336 boolean OCI_API OCI_DirPathSetCurrentRows 01337 ( 01338 OCI_DirPath *dp, 01339 unsigned int nb_rows 01340 ) 01341 { 01342 boolean res = TRUE; 01343 01344 OCI_CHECK_PTR(OCI_IPC_DIRPATH, dp, FALSE); 01345 01346 OCI_CHECK_DIRPATH_STATUS(dp, OCI_DPS_PREPARED, FALSE); 01347 01348 OCI_CHECK_BOUND(dp->con, nb_rows, 1, dp->nb_rows, FALSE); 01349 01350 dp->nb_cur = (ub2) nb_rows; 01351 01352 OCI_RESULT(res); 01353 01354 return res; 01355 } 01356 01357 /* --------------------------------------------------------------------------------------------- * 01358 * OCI_DirPathGetCurrentRows 01359 * --------------------------------------------------------------------------------------------- */ 01360 01361 unsigned int OCI_API OCI_DirPathGetCurrentRows 01362 ( 01363 OCI_DirPath *dp 01364 ) 01365 { 01366 OCI_CHECK_PTR(OCI_IPC_DIRPATH, dp, 0); 01367 01368 OCI_RESULT(TRUE); 01369 01370 return dp->nb_cur; 01371 } 01372 01373 /* --------------------------------------------------------------------------------------------- * 01374 * OCI_DirPathGetMaxRows 01375 * --------------------------------------------------------------------------------------------- */ 01376 01377 unsigned int OCI_API OCI_DirPathGetMaxRows 01378 ( 01379 OCI_DirPath *dp 01380 ) 01381 { 01382 OCI_CHECK_PTR(OCI_IPC_DIRPATH, dp, 0); 01383 01384 OCI_RESULT(TRUE); 01385 01386 return dp->nb_rows; 01387 } 01388 01389 /* --------------------------------------------------------------------------------------------- * 01390 * OCI_DirPathSetDateFormat 01391 * --------------------------------------------------------------------------------------------- */ 01392 01393 boolean OCI_API OCI_DirPathSetDateFormat 01394 ( 01395 OCI_DirPath *dp, 01396 const mtext *format 01397 ) 01398 { 01399 boolean res = TRUE; 01400 void *ostr = NULL; 01401 int osize = -1; 01402 01403 OCI_CHECK_PTR(OCI_IPC_DIRPATH, dp, FALSE); 01404 01405 OCI_CHECK_DIRPATH_STATUS(dp, OCI_DPS_NOT_PREPARED, FALSE); 01406 01407 osize = -1; 01408 ostr = OCI_GetInputMetaString(format, &osize); 01409 01410 OCI_CALL2 01411 ( 01412 res, dp->con, 01413 01414 OCIAttrSet((dvoid *) dp->ctx, (ub4) OCI_HTYPE_DIRPATH_CTX, 01415 (dvoid *) ostr, (ub4) osize, (ub4) OCI_ATTR_DATEFORMAT, dp->con->err) 01416 ) 01417 01418 OCI_ReleaseMetaString(ostr); 01419 01420 OCI_RESULT(res); 01421 01422 return res; 01423 } 01424 01425 /* --------------------------------------------------------------------------------------------- * 01426 * OCI_DirPathSetParallel 01427 * --------------------------------------------------------------------------------------------- */ 01428 01429 boolean OCI_API OCI_DirPathSetParallel 01430 ( 01431 OCI_DirPath *dp, 01432 boolean value 01433 ) 01434 { 01435 boolean res = TRUE; 01436 ub1 enabled = (ub1) value; 01437 01438 OCI_CHECK_PTR(OCI_IPC_DIRPATH, dp, FALSE); 01439 01440 OCI_CHECK_DIRPATH_STATUS(dp, OCI_DPS_NOT_PREPARED, FALSE); 01441 01442 OCI_CALL2 01443 ( 01444 res, dp->con, 01445 01446 OCIAttrSet((dvoid *) dp->ctx, (ub4) OCI_HTYPE_DIRPATH_CTX, 01447 (dvoid *) &enabled, (ub4) sizeof(enabled), 01448 (ub4) OCI_ATTR_DIRPATH_PARALLEL, dp->con->err) 01449 ) 01450 01451 OCI_RESULT(res); 01452 01453 return res; 01454 } 01455 01456 /* --------------------------------------------------------------------------------------------- * 01457 * OCI_DirPathSetNoLog 01458 * --------------------------------------------------------------------------------------------- */ 01459 01460 boolean OCI_API OCI_DirPathSetNoLog 01461 ( 01462 OCI_DirPath *dp, 01463 boolean value 01464 ) 01465 { 01466 boolean res = TRUE; 01467 ub1 nolog = (ub1) value; 01468 01469 OCI_CHECK_PTR(OCI_IPC_DIRPATH, dp, FALSE); 01470 01471 OCI_CHECK_DIRPATH_STATUS(dp, OCI_DPS_NOT_PREPARED, FALSE); 01472 01473 OCI_CALL2 01474 ( 01475 res, dp->con, 01476 01477 OCIAttrSet((dvoid *) dp->ctx, (ub4) OCI_HTYPE_DIRPATH_CTX, 01478 (dvoid *) &nolog, (ub4) sizeof(nolog), 01479 (ub4) OCI_ATTR_DIRPATH_NOLOG, dp->con->err) 01480 ) 01481 01482 OCI_RESULT(res); 01483 01484 return res; 01485 } 01486 01487 /* --------------------------------------------------------------------------------------------- * 01488 * OCI_DirPathSetCacheSize 01489 * --------------------------------------------------------------------------------------------- */ 01490 01491 boolean OCI_API OCI_DirPathSetCacheSize 01492 ( 01493 OCI_DirPath *dp, 01494 unsigned int size 01495 ) 01496 { 01497 boolean res = TRUE; 01498 ub4 cache_size = size; 01499 boolean enabled = FALSE; 01500 01501 OCI_CHECK_PTR(OCI_IPC_DIRPATH, dp, FALSE); 01502 01503 OCI_CHECK_DIRPATH_DATE_CACHE_ENABLED(dp, FALSE); 01504 01505 OCI_CHECK_DIRPATH_STATUS(dp, OCI_DPS_NOT_PREPARED, FALSE); 01506 01507 #if OCI_VERSION_COMPILE >= OCI_9_2 01508 01509 OCI_CALL2 01510 ( 01511 res, dp->con, 01512 01513 OCIAttrSet((dvoid *) dp->ctx, (ub4) OCI_HTYPE_DIRPATH_CTX, 01514 (dvoid *) &cache_size, (ub4) sizeof(cache_size), 01515 (ub4) OCI_ATTR_DIRPATH_DCACHE_SIZE, dp->con->err) 01516 ) 01517 01518 OCI_CALL2 01519 ( 01520 res, dp->con, 01521 01522 OCIAttrSet((dvoid *) dp->ctx, (ub4) OCI_HTYPE_DIRPATH_CTX, 01523 (dvoid *) &enabled, (ub4) sizeof(enabled), 01524 (ub4) OCI_ATTR_DIRPATH_DCACHE_DISABLE, dp->con->err) 01525 ) 01526 01527 #else 01528 01529 OCI_NOT_USED(cache_size); 01530 OCI_NOT_USED(enabled); 01531 01532 #endif 01533 01534 OCI_RESULT(res); 01535 01536 return res; 01537 } 01538 01539 /* --------------------------------------------------------------------------------------------- * 01540 * OCI_DirPathSetBufferSize 01541 * --------------------------------------------------------------------------------------------- */ 01542 01543 boolean OCI_API OCI_DirPathSetBufferSize 01544 ( 01545 OCI_DirPath *dp, 01546 unsigned int size 01547 ) 01548 { 01549 boolean res = TRUE; 01550 ub4 bufsize = (ub4) size; 01551 01552 OCI_CHECK_PTR(OCI_IPC_DIRPATH, dp, FALSE); 01553 01554 OCI_CHECK_DIRPATH_STATUS(dp, OCI_DPS_NOT_PREPARED, FALSE); 01555 01556 OCI_CALL2 01557 ( 01558 res, dp->con, 01559 01560 OCIAttrSet((dvoid *) dp->ctx, (ub4) OCI_HTYPE_DIRPATH_CTX, 01561 (dvoid *) &bufsize, (ub4) sizeof(bufsize), 01562 (ub4) OCI_ATTR_BUF_SIZE, dp->con->err) 01563 ) 01564 01565 OCI_RESULT(res); 01566 01567 return res; 01568 } 01569 01570 /* --------------------------------------------------------------------------------------------- * 01571 * OCI_DirPathSetConvertMode 01572 * --------------------------------------------------------------------------------------------- */ 01573 01574 boolean OCI_API OCI_DirPathSetConvertMode 01575 ( 01576 OCI_DirPath *dp, 01577 unsigned int mode 01578 ) 01579 { 01580 boolean res = TRUE; 01581 01582 OCI_CHECK_PTR(OCI_IPC_DIRPATH, dp, FALSE); 01583 01584 dp->cvt_mode = (ub2) mode; 01585 01586 OCI_RESULT(res); 01587 01588 return res; 01589 } 01590 01591 /* --------------------------------------------------------------------------------------------- * 01592 * OCI_DirPathGetRowCount 01593 * --------------------------------------------------------------------------------------------- */ 01594 01595 unsigned int OCI_API OCI_DirPathGetRowCount 01596 ( 01597 OCI_DirPath *dp 01598 ) 01599 { 01600 OCI_CHECK_PTR(OCI_IPC_DIRPATH, dp, FALSE); 01601 01602 OCI_RESULT(TRUE); 01603 01604 return dp->nb_loaded; 01605 } 01606 01607 /* --------------------------------------------------------------------------------------------- * 01608 * OCI_DirPathGetAffectedRows 01609 * --------------------------------------------------------------------------------------------- */ 01610 01611 unsigned int OCI_API OCI_DirPathGetAffectedRows 01612 ( 01613 OCI_DirPath *dp 01614 ) 01615 { 01616 OCI_CHECK_PTR(OCI_IPC_DIRPATH, dp, FALSE); 01617 01618 OCI_RESULT(TRUE); 01619 01620 return dp->nb_processed; 01621 } 01622 01623 /* --------------------------------------------------------------------------------------------- * 01624 * OCI_DirPathGetErrorColumn 01625 * --------------------------------------------------------------------------------------------- */ 01626 01627 unsigned int OCI_API OCI_DirPathGetErrorColumn 01628 ( 01629 OCI_DirPath *dp 01630 ) 01631 { 01632 ub2 err_col = 0; 01633 01634 OCI_CHECK_PTR(OCI_IPC_DIRPATH, dp, FALSE); 01635 01636 OCI_RESULT(TRUE); 01637 01638 if (dp->idx_err_col < dp->nb_err) 01639 { 01640 err_col = dp->err_cols[dp->idx_err_col++] + 1; 01641 } 01642 01643 return err_col; 01644 } 01645 01646 /* --------------------------------------------------------------------------------------------- * 01647 * OCI_DirPathGetErrorRow 01648 * --------------------------------------------------------------------------------------------- */ 01649 01650 unsigned int OCI_API OCI_DirPathGetErrorRow 01651 ( 01652 OCI_DirPath *dp 01653 ) 01654 { 01655 ub4 err_row = 0; 01656 01657 OCI_CHECK_PTR(OCI_IPC_DIRPATH, dp, FALSE); 01658 01659 OCI_RESULT(TRUE); 01660 01661 if (dp->idx_err_row < dp->nb_err) 01662 { 01663 err_row = dp->err_rows[dp->idx_err_row++] + 1; 01664 } 01665 01666 return err_row; 01667 }