OCILIB (C Driver for Oracle) 3.9.2
D:/Perso/dev/ocilib/ocilib/src/bind.c
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-2011 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: bind.c, v 3.9.2 2011-07-13 00:00 Vincent Rogier $
00033  * --------------------------------------------------------------------------------------------- */
00034 
00035 #include "ocilib_internal.h"
00036 
00037 /* ********************************************************************************************* *
00038  *                             PRIVATE FUNCTIONS
00039  * ********************************************************************************************* */
00040 
00041 /* --------------------------------------------------------------------------------------------- *
00042  * OCI_BindFree
00043  * --------------------------------------------------------------------------------------------- */
00044 
00045 boolean OCI_BindFree
00046 (
00047     OCI_Bind *bnd
00048 )
00049 {
00050     if (bnd->stmt->bind_alloc_mode == OCI_BAM_INTERNAL)
00051     {
00052         if (bnd->is_array)
00053         {
00054             OCI_ArrayFreeFromHandles(bnd->input);
00055         }
00056         else
00057         {
00058             switch (bnd->type)
00059             {
00060                 case OCI_CDT_NUMERIC:
00061                 {
00062                     OCI_MemFree(bnd->input);
00063                     
00064                     if (bnd->alloc == TRUE)
00065                     {
00066                         OCI_FREE(bnd->buf.data);
00067                     }                    
00068                     
00069                     break;
00070                 }
00071                 case OCI_CDT_TEXT:
00072                 {
00073                     OCI_MemFree(bnd->input);
00074                     
00075                     if (bnd->alloc == TRUE)
00076                     {
00077                         OCI_FREE(bnd->buf.data);
00078                     }                    
00079 
00080                     break;
00081                 }
00082                 case OCI_CDT_DATETIME:
00083                 {
00084                     OCI_DateFree((OCI_Date *) bnd->input);
00085                     break;
00086                 }
00087                 case OCI_CDT_LOB:
00088                 {
00089                     OCI_LobFree((OCI_Lob *) bnd->input);
00090                     break;
00091                 }
00092                 case OCI_CDT_FILE:
00093                 {
00094                     OCI_FileFree((OCI_File *) bnd->input);
00095                     break;
00096                 }
00097                 case OCI_CDT_OBJECT:
00098                 {
00099                     OCI_ObjectFree((OCI_Object *) bnd->input);
00100                     break;
00101                 }
00102                 case OCI_CDT_COLLECTION:
00103                 {
00104                     OCI_CollFree((OCI_Coll *) bnd->input);;
00105                     break;
00106                 }
00107                 case OCI_CDT_TIMESTAMP:
00108                 {
00109                     OCI_TimestampFree((OCI_Timestamp *) bnd->input);
00110                     break;
00111                 }
00112                 case OCI_CDT_INTERVAL:
00113                 {
00114                     OCI_IntervalFree((OCI_Interval *) bnd->input);
00115                     break;
00116                 }
00117                 case OCI_CDT_REF:
00118                 {
00119                     OCI_RefFree((OCI_Ref *) bnd->input);
00120                     break;
00121                 }
00122                 default:
00123                 {
00124                     OCI_MemFree(bnd->input);
00125                 }
00126             }
00127         }
00128     }
00129     else
00130     {
00131         if (bnd->alloc == TRUE)
00132         {
00133             OCI_FREE(bnd->buf.data);
00134         }
00135     }
00136 
00137     OCI_FREE(bnd->buf.inds);
00138     OCI_FREE(bnd->buf.obj_inds);
00139     OCI_FREE(bnd->buf.lens);
00140     OCI_FREE(bnd->buf.tmpbuf);
00141 
00142     OCI_FREE(bnd->plrcds);
00143 
00144     OCI_FREE(bnd->name);
00145     OCI_FREE(bnd);
00146 
00147     return TRUE;
00148 }
00149 
00150 /* --------------------------------------------------------------------------------------------- *
00151  * OCI_BindAllocData
00152  * --------------------------------------------------------------------------------------------- */
00153 
00154 boolean OCI_BindAllocData
00155 (
00156     OCI_Bind *bnd
00157 )
00158 {
00159     boolean res = FALSE;
00160 
00161     if (bnd->is_array)
00162     {
00163         unsigned int struct_size = 0;
00164         unsigned int elem_size   = 0;
00165         unsigned int handle_type = 0;
00166 
00167         OCI_Array *arr = NULL;
00168 
00169         switch (bnd->type)
00170         {
00171             case OCI_CDT_NUMERIC:
00172             {
00173                 if (bnd->code == SQLT_VNU)
00174                 {
00175                     struct_size = sizeof(big_int);
00176                     elem_size   = sizeof(OCINumber);
00177                 }
00178                 else
00179                 {
00180                     struct_size = bnd->size;
00181                 }
00182                 break;
00183             }
00184             case OCI_CDT_DATETIME:
00185             {
00186                 struct_size = sizeof(OCI_Date);
00187                 elem_size   = sizeof(OCIDate);
00188                 break;
00189             }
00190             case OCI_CDT_TEXT:
00191             {
00192                 struct_size = bnd->size;
00193 
00194             #ifdef OCI_CHECK_DATASTRINGS
00195 
00196                 elem_size   = bnd->size * (sizeof(dtext) / sizeof(odtext));
00197 
00198             #endif
00199 
00200                 break;
00201             }
00202             case OCI_CDT_LOB:
00203             {
00204                 struct_size = sizeof(OCI_Lob);
00205                 elem_size   = sizeof(OCILobLocator *);
00206                 handle_type = OCI_DTYPE_LOB;
00207                 break;
00208             }
00209             case OCI_CDT_FILE:
00210             {
00211                 struct_size = sizeof(OCI_File);
00212                 elem_size   = sizeof(OCILobLocator *);
00213                 handle_type = OCI_DTYPE_LOB;
00214                 break;
00215             }
00216             case OCI_CDT_TIMESTAMP:
00217             {
00218                 struct_size = sizeof(OCI_Timestamp);
00219                 elem_size   = sizeof(OCIDateTime *);
00220 
00221                 if (bnd->subtype == OCI_TIMESTAMP)
00222                 {
00223                     handle_type = OCI_DTYPE_TIMESTAMP;
00224                 }
00225                 else if (bnd->subtype == OCI_TIMESTAMP_TZ)
00226                 {
00227                     handle_type = OCI_DTYPE_TIMESTAMP_TZ;
00228                 }
00229                 else if (bnd->subtype == OCI_TIMESTAMP_LTZ)
00230                 {
00231                     handle_type = OCI_DTYPE_TIMESTAMP_LTZ;
00232                 }
00233 
00234                 break;
00235             }
00236             case OCI_CDT_INTERVAL:
00237             {
00238                 struct_size = sizeof(OCI_Interval);
00239                 elem_size   = sizeof(OCIInterval *);
00240 
00241                 if (bnd->subtype == OCI_INTERVAL_YM)
00242                 {
00243                     handle_type = OCI_DTYPE_INTERVAL_YM;
00244                 }
00245                 else if (bnd->subtype == OCI_INTERVAL_DS)
00246                 {
00247                     handle_type = OCI_DTYPE_INTERVAL_DS;
00248                 }
00249 
00250                 break;
00251             }
00252             case OCI_CDT_RAW:
00253             {
00254                 struct_size = bnd->size;
00255                 break;
00256             }
00257             case OCI_CDT_OBJECT:
00258             {
00259                 struct_size = sizeof(OCI_Object);
00260                 elem_size   = sizeof(void *);
00261                 break;
00262             }
00263             case OCI_CDT_COLLECTION:
00264             {
00265                 struct_size = sizeof(OCI_Coll);
00266                 elem_size   = sizeof(OCIColl *);
00267                 break;
00268             }
00269             case OCI_CDT_REF:
00270             {
00271                 struct_size = sizeof(OCI_Ref);
00272                 elem_size   = sizeof(OCIRef *);
00273                 break;
00274             }
00275         }
00276 
00277         arr = OCI_ArrayCreate(bnd->stmt->con, bnd->buf.count, bnd->type, bnd->subtype,
00278                               elem_size, struct_size, handle_type, bnd->typinf);
00279 
00280         if (arr != NULL)
00281         {
00282             switch (bnd->type)
00283             {
00284                 case OCI_CDT_NUMERIC:
00285                 {
00286                     if (bnd->code == SQLT_VNU)
00287                     {
00288                         bnd->buf.data = (void **) arr->mem_handle;
00289                         bnd->input    = (void **) arr->mem_struct;
00290                         bnd->alloc    = TRUE;
00291                     }
00292                     else
00293                     {
00294                         bnd->buf.data = (void **) arr->mem_struct;
00295                         bnd->input    = (void **) bnd->buf.data;
00296                     }
00297                     break;
00298                 }
00299                 case OCI_CDT_TEXT:
00300                 {
00301 
00302             #ifdef OCI_CHECK_DATASTRINGS
00303 
00304                     bnd->buf.data = (void **) arr->mem_handle;
00305                     bnd->input    = (void **) arr->mem_struct;
00306                     bnd->alloc    = TRUE;
00307             #else
00308 
00309                     bnd->buf.data = (void **) arr->mem_struct;
00310                     bnd->input    = (void **) bnd->buf.data;
00311 
00312             #endif
00313 
00314                     break;
00315                 }
00316                 case OCI_CDT_RAW:
00317                 {
00318                     bnd->buf.data = (void **) arr->mem_struct;
00319                     bnd->input    = (void **) bnd->buf.data;
00320                     break;
00321                 }
00322                 case OCI_CDT_DATETIME:
00323                 case OCI_CDT_LOB:
00324                 case OCI_CDT_FILE:
00325                 case OCI_CDT_TIMESTAMP:
00326                 case OCI_CDT_INTERVAL:
00327                 case OCI_CDT_OBJECT:
00328                 case OCI_CDT_COLLECTION:
00329                 case OCI_CDT_REF:
00330                 {
00331                     bnd->buf.data = (void **) arr->mem_handle;
00332                     bnd->input    = (void **) arr->tab_obj;
00333                     break;
00334                 }
00335             }
00336         }
00337     }
00338     else
00339     {
00340         switch (bnd->type)
00341         {
00342             case OCI_CDT_NUMERIC:
00343             {
00344                 if (bnd->code == SQLT_VNU)
00345                 {
00346                     bnd->input    = (void **) OCI_MemAlloc(OCI_IPC_VOID, sizeof(big_int),   1, TRUE);
00347                     bnd->buf.data = (void **) OCI_MemAlloc(OCI_IPC_VOID, sizeof(OCINumber), 1, TRUE);
00348                 }
00349                 else
00350                 {
00351                     bnd->input    = (void **) OCI_MemAlloc(OCI_IPC_VOID, bnd->size, 1, TRUE);
00352                     bnd->buf.data = (void **) bnd->input;
00353                 }
00354                 break;
00355             }
00356             case OCI_CDT_DATETIME:
00357             {
00358                 OCI_Date *date = OCI_DateCreate(bnd->stmt->con);
00359 
00360                 if (date != NULL)
00361                 {
00362                     bnd->input    = (void **) date;
00363                     bnd->buf.data = (void **) date->handle;
00364                 }
00365 
00366                 break;
00367             }
00368             case OCI_CDT_TEXT:
00369             {
00370 
00371             #ifdef OCI_CHECK_DATASTRINGS
00372 
00373                     bnd->buf.data = (void **) OCI_MemAlloc(OCI_IPC_STRING, bnd->size * (sizeof(dtext) / sizeof(odtext)), 1, TRUE);
00374                     bnd->input    = (void **) OCI_MemAlloc(OCI_IPC_STRING, bnd->size, 1, TRUE);
00375             #else
00376 
00377                     bnd->buf.data = (void **) OCI_MemAlloc(OCI_IPC_STRING, bnd->size, 1, TRUE);
00378                     bnd->input    = (void **) bnd->buf.data;
00379 
00380             #endif
00381 
00382                 break;
00383             }
00384             case OCI_CDT_LOB:
00385             {
00386                 OCI_Lob *lob = OCI_LobCreate(bnd->stmt->con, bnd->subtype);
00387 
00388                 if (lob != NULL)
00389                 {
00390                     bnd->input    = (void **) lob;
00391                     bnd->buf.data = (void **) lob->handle;
00392                 }
00393 
00394                 break;
00395             }
00396             case OCI_CDT_FILE:
00397             {
00398                 OCI_File *file = OCI_FileCreate(bnd->stmt->con,  bnd->subtype);
00399 
00400                 if (file != NULL)
00401                 {
00402                     bnd->input    = (void **) file;
00403                     bnd->buf.data = (void **) file->handle;
00404                 }
00405 
00406                 break;
00407             }
00408             case OCI_CDT_TIMESTAMP:
00409             {
00410                 OCI_Timestamp *tmsp = OCI_TimestampCreate(bnd->stmt->con, bnd->subtype);
00411 
00412                 if (tmsp != NULL)
00413                 {
00414                     bnd->input    = (void **) tmsp;
00415                     bnd->buf.data = (void **) tmsp->handle;
00416                 }
00417 
00418                 break;
00419             }
00420             case OCI_CDT_INTERVAL:
00421             {
00422                 OCI_Interval *itv = OCI_IntervalCreate(bnd->stmt->con, bnd->subtype);
00423 
00424                 if (itv != NULL)
00425                 {
00426                     bnd->input    = (void **) itv;
00427                     bnd->buf.data = (void **) itv->handle;
00428                 }
00429 
00430                 break;
00431             }
00432             case OCI_CDT_RAW:
00433             {
00434                 bnd->input    = (void **) OCI_MemAlloc(OCI_IPC_VOID, bnd->size, 1, TRUE);
00435                 bnd->buf.data = (void **) bnd->input;
00436                 break;
00437             }
00438             case OCI_CDT_OBJECT:
00439             {
00440                 OCI_Object *obj = OCI_ObjectCreate(bnd->stmt->con, bnd->typinf);
00441 
00442                 if (obj != NULL)
00443                 {
00444                     bnd->input    = (void **) obj;
00445                     bnd->buf.data = (void **) obj->handle;
00446                 }
00447 
00448                 break;
00449             }
00450             case OCI_CDT_COLLECTION:
00451             {
00452                 OCI_Coll *coll = OCI_CollCreate(bnd->typinf);
00453 
00454                 if (coll != NULL)
00455                 {
00456                     bnd->input    = (void **) coll;
00457                     bnd->buf.data = (void **) coll->handle;
00458                 }
00459 
00460                 break;
00461             }
00462             case OCI_CDT_REF:
00463             {
00464                 OCI_Ref *ref =  OCI_RefCreate(bnd->stmt->con, bnd->typinf);
00465 
00466                 if (ref != NULL)
00467                 {
00468                     bnd->input    = (void **) ref;
00469                     bnd->buf.data = (void **) ref->handle;
00470                 }
00471 
00472                 break;
00473             }
00474         }
00475     }
00476 
00477     res = (bnd->input != NULL);
00478 
00479     return res;
00480 }
00481 
00482 /* ********************************************************************************************* *
00483  *                            PUBLIC FUNCTIONS
00484  * ********************************************************************************************* */
00485 
00486 /* --------------------------------------------------------------------------------------------- *
00487  * OCI_BindGetName
00488  * --------------------------------------------------------------------------------------------- */
00489 
00490 const mtext * OCI_API OCI_BindGetName
00491 (
00492     OCI_Bind *bnd
00493 )
00494 {
00495     OCI_CHECK_PTR(OCI_IPC_BIND, bnd, NULL);
00496 
00497     OCI_RESULT(TRUE);
00498 
00499     return (const mtext *) bnd->name;
00500 }
00501 
00502 /* --------------------------------------------------------------------------------------------- *
00503  * OCI_BindGetType
00504  * --------------------------------------------------------------------------------------------- */
00505 
00506 unsigned int OCI_API OCI_BindGetType
00507 (
00508     OCI_Bind *bnd
00509 )
00510 {
00511     OCI_CHECK_PTR(OCI_IPC_BIND, bnd, OCI_UNKNOWN);
00512 
00513     OCI_RESULT(TRUE);
00514 
00515     return (unsigned int) bnd->type;
00516 }
00517 
00518 /* --------------------------------------------------------------------------------------------- *
00519  * OCI_BindGetSubtype
00520  * --------------------------------------------------------------------------------------------- */
00521 
00522 unsigned int OCI_API OCI_BindGetSubtype
00523 (
00524     OCI_Bind *bnd
00525 )
00526 {
00527     unsigned int type = OCI_UNKNOWN;
00528 
00529     OCI_CHECK_PTR(OCI_IPC_BIND, bnd, OCI_UNKNOWN);
00530 
00531     OCI_RESULT(TRUE);
00532 
00533     if (bnd->type == OCI_CDT_NUMERIC   ||
00534         bnd->type == OCI_CDT_LONG      ||
00535         bnd->type == OCI_CDT_LOB       ||
00536         bnd->type == OCI_CDT_FILE      ||
00537         bnd->type == OCI_CDT_TIMESTAMP ||
00538         bnd->type == OCI_CDT_INTERVAL)
00539     {
00540         type = bnd->subtype;
00541     }
00542 
00543     return type;
00544 }
00545 
00546 /* --------------------------------------------------------------------------------------------- *
00547  * OCI_BindGetDataCount
00548  * --------------------------------------------------------------------------------------------- */
00549 
00550 unsigned int OCI_API OCI_BindGetDataCount
00551 (
00552     OCI_Bind *bnd
00553 )
00554 {
00555     OCI_CHECK_PTR(OCI_IPC_BIND, bnd, 0);
00556 
00557     OCI_RESULT(TRUE);
00558 
00559     return (unsigned int) bnd->buf.count;
00560 }
00561 
00562 /* --------------------------------------------------------------------------------------------- *
00563  * OCI_BindGetData
00564  * --------------------------------------------------------------------------------------------- */
00565 
00566 void * OCI_API OCI_BindGetData
00567 (
00568     OCI_Bind *bnd
00569 )
00570 {
00571     OCI_CHECK_PTR(OCI_IPC_BIND, bnd, NULL);
00572 
00573     OCI_RESULT(TRUE);
00574 
00575     return (void *) bnd->input;
00576 }
00577 
00578 /* --------------------------------------------------------------------------------------------- *
00579  * OCI_BindGetStatement
00580  * --------------------------------------------------------------------------------------------- */
00581 
00582 OCI_EXPORT OCI_Statement * OCI_API OCI_BindGetStatement
00583 (
00584     OCI_Bind *bnd
00585 )
00586 {
00587     OCI_CHECK_PTR(OCI_IPC_BIND, bnd, NULL);
00588 
00589     OCI_RESULT(TRUE);
00590 
00591     return bnd->stmt;
00592 }
00593 
00594 /* --------------------------------------------------------------------------------------------- *
00595  * OCI_BindSetDataSize
00596  * --------------------------------------------------------------------------------------------- */
00597 
00598 boolean OCI_API OCI_BindSetDataSize
00599 (
00600     OCI_Bind    *bnd,
00601     unsigned int size
00602 )
00603 {
00604     return OCI_BindSetDataSizeAtPos(bnd, 1, size);
00605 }
00606 
00607 /* --------------------------------------------------------------------------------------------- *
00608  * OCI_BindSetDataSizeAtPos
00609  * --------------------------------------------------------------------------------------------- */
00610 
00611 boolean OCI_API OCI_BindSetDataSizeAtPos
00612 (
00613     OCI_Bind    *bnd,
00614     unsigned int position,
00615     unsigned int size
00616 )
00617 {
00618     boolean res = FALSE;
00619 
00620     OCI_CHECK_PTR(OCI_IPC_BIND, bnd, FALSE);
00621     OCI_CHECK_BOUND(bnd->stmt->con, position, 1, bnd->buf.count, FALSE);
00622     OCI_CHECK_MIN(bnd->stmt->con, bnd->stmt, size, 1, FALSE);
00623 
00624     if (bnd->buf.lens != NULL)
00625     {
00626 
00627         if (bnd->type == OCI_CDT_TEXT)
00628         {
00629             if (bnd->size == (sb4) size)
00630             {
00631                 size += (unsigned int) (size_t) sizeof(odtext);
00632             }
00633 
00634             size *= (unsigned int) sizeof(odtext);
00635         }
00636 
00637         ((ub2 *) bnd->buf.lens)[position-1] = (ub2) size;
00638 
00639         res = TRUE;
00640     }
00641 
00642     OCI_RESULT(TRUE);
00643 
00644     return res;
00645 }
00646 
00647 /* --------------------------------------------------------------------------------------------- *
00648  * OCI_BindGetDataSize
00649  * --------------------------------------------------------------------------------------------- */
00650 
00651 unsigned int OCI_API OCI_BindGetDataSize
00652 (
00653     OCI_Bind *bnd
00654 )
00655 {
00656     return OCI_BindGetDataSizeAtPos(bnd, 1);
00657 }
00658 
00659 /* --------------------------------------------------------------------------------------------- *
00660  * OCI_BindGetDataSizeAtPos
00661  * --------------------------------------------------------------------------------------------- */
00662 
00663 unsigned int OCI_API OCI_BindGetDataSizeAtPos
00664 (
00665     OCI_Bind    *bnd,
00666     unsigned int position
00667 )
00668 {
00669     unsigned int size = 0;
00670 
00671     OCI_CHECK_PTR(OCI_IPC_BIND, bnd, 0);
00672     OCI_CHECK_BOUND(bnd->stmt->con, position, 1, bnd->buf.count, 0);
00673 
00674     if (bnd->buf.lens != NULL)
00675     {
00676         size = (unsigned int) ((ub2 *) bnd->buf.lens)[position-1];
00677 
00678         if (bnd->type == OCI_CDT_TEXT)
00679         {
00680             if (bnd->size == (sb4) size)
00681             {
00682                 size -= (unsigned int) sizeof(odtext);
00683             }
00684 
00685             size /= (unsigned int) sizeof(odtext);
00686         }
00687     }
00688 
00689     OCI_RESULT(TRUE);
00690 
00691     return size;
00692 }
00693 
00694 /* --------------------------------------------------------------------------------------------- *
00695  * OCI_BindSetNullAtPos
00696  * --------------------------------------------------------------------------------------------- */
00697 
00698 boolean OCI_API OCI_BindSetNullAtPos
00699 (
00700     OCI_Bind    *bnd,
00701     unsigned int position
00702 )
00703 {
00704     OCI_CHECK_PTR(OCI_IPC_BIND, bnd, FALSE);
00705     OCI_CHECK_BOUND(bnd->stmt->con, position, 1, bnd->buf.count, FALSE);
00706 
00707     if (bnd->buf.inds != NULL)
00708     {
00709         ((sb2*) bnd->buf.inds)[position-1] = -1;
00710     }
00711 
00712     OCI_RESULT(TRUE);
00713 
00714     return TRUE;
00715 }
00716 
00717 /* --------------------------------------------------------------------------------------------- *
00718  * OCI_BindSetNull
00719  * --------------------------------------------------------------------------------------------- */
00720 
00721 boolean OCI_API OCI_BindSetNull
00722 (
00723     OCI_Bind *bnd
00724 )
00725 {
00726     return OCI_BindSetNullAtPos(bnd, 1);
00727 }
00728 
00729 /* --------------------------------------------------------------------------------------------- *
00730  * OCI_BindIsNullAtPos
00731  * --------------------------------------------------------------------------------------------- */
00732 
00733 boolean OCI_API OCI_BindIsNullAtPos
00734 (
00735     OCI_Bind    *bnd,
00736     unsigned int position
00737 )
00738 {
00739     boolean ret = TRUE;
00740 
00741     OCI_CHECK_PTR(OCI_IPC_BIND, bnd, FALSE);
00742     OCI_CHECK_BOUND(bnd->stmt->con, position, 1, bnd->buf.count, FALSE);
00743 
00744     if (bnd->buf.inds != NULL)
00745     {
00746         ret = (((sb2*) bnd->buf.inds)[position-1] == -1);
00747     }
00748 
00749     OCI_RESULT(TRUE);
00750 
00751     return ret;
00752 }
00753 
00754 /* --------------------------------------------------------------------------------------------- *
00755  * OCI_BindIsNull
00756  * --------------------------------------------------------------------------------------------- */
00757 
00758 boolean OCI_API OCI_BindIsNull
00759 (
00760     OCI_Bind *bnd
00761 )
00762 {
00763     return OCI_BindIsNullAtPos(bnd, 1);
00764 }
00765 
00766 /* --------------------------------------------------------------------------------------------- *
00767  * OCI_BindSetCharsetForm
00768  * --------------------------------------------------------------------------------------------- */
00769 
00770 boolean OCI_API OCI_BindSetCharsetForm
00771 (
00772     OCI_Bind    *bnd,
00773     unsigned int csfrm
00774 )
00775 {
00776     boolean res = TRUE;
00777 
00778     OCI_CHECK_PTR(OCI_IPC_BIND, bnd, FALSE);
00779 
00780     if ((bnd->type == OCI_CDT_TEXT) || (bnd->type == OCI_CDT_LONG))
00781     {
00782         if (csfrm == OCI_CSF_NATIONAL)
00783         {
00784             bnd->csfrm = SQLCS_NCHAR;
00785         }
00786         else if (csfrm == OCI_CSF_DEFAULT)
00787         {
00788             bnd->csfrm = SQLCS_IMPLICIT;
00789         }
00790 
00791         OCI_CALL1
00792         (
00793             res, bnd->stmt->con, bnd->stmt,
00794 
00795             OCIAttrSet((dvoid *) bnd->buf.handle,
00796                        (ub4    ) OCI_HTYPE_BIND,
00797                        (dvoid *) &bnd->csfrm,
00798                        (ub4    ) sizeof(bnd->csfrm),
00799                        (ub4    ) OCI_ATTR_CHARSET_FORM,
00800                        bnd->stmt->con->err)
00801         )
00802     }
00803 
00804     OCI_RESULT(res);
00805 
00806     return res;
00807 }
00808 
00809 /* --------------------------------------------------------------------------------------------- *
00810  * OCI_BindSetDirection
00811  * --------------------------------------------------------------------------------------------- */
00812 
00813 boolean OCI_API OCI_BindSetDirection
00814 (
00815     OCI_Bind    *bnd,
00816     unsigned int direction
00817 )
00818 {
00819     boolean res = TRUE;
00820 
00821     OCI_CHECK_PTR(OCI_IPC_BIND, bnd, FALSE);
00822 
00823     bnd->direction = (ub1) direction;
00824 
00825     OCI_RESULT(res);
00826 
00827     return res;
00828 }
00829 
00830 /* --------------------------------------------------------------------------------------------- *
00831  * OCI_BindGetDirection
00832  * --------------------------------------------------------------------------------------------- */
00833 
00834 unsigned int OCI_API OCI_BindGetDirection
00835 (
00836     OCI_Bind *bnd
00837 )
00838 {
00839     OCI_CHECK_PTR(OCI_IPC_BIND, bnd, OCI_UNKNOWN);
00840 
00841     OCI_RESULT(TRUE);
00842 
00843     return bnd->direction;
00844 }
00845