Programmer's Guide to the Oracle Call Interface
Release 8.0

A54656_01

Library

Product

Contents

Index

Prev Next

15
OCI Datatype Mapping and Manipulation Functions

This chapter describes the OCI datatype mapping and manipulation functions, which is Oracle's external C Language interface to Oracle8 predefined types.

The following sections are included in this chapter:

Introduction

This chapter describes the OCI datatype mapping and manipulation functions in detail.

See Also: For more information about the functions listed in this chapter, refer to Chapter 9, "Object-Relational Datatypes".

Datatype Mapping and Manipulation Function Return Values

The OCI datatype mapping and manipulation functions typically return one of the following values:

Table 15-1 Common Navigational Function Return Values
Return Value   Meaning  

OCI_SUCCESS  

The operation succeeded  

OCI_ERROR  

The operation failed. The specific error can be retrieved by calling OCIErrorGet() on the error handle passed to the function.  

OCI_INVALID_HANDLE  

The environment or error handle passed to the function is NULL.  

Function-specific return information follows the description of each function in this chapter. For more information about return codes and error handling, see the section "Error Handling" on page 2-25.

Functions Returning Other Values

Some functions return values other than those listed in Table 15-1. When using these function be sure to take into account that they return a value directly from the function call, rather than through an OUT parameter.

Server Roundtrips for Datatype Mapping and Manipulation Functions

For a table showing the number of server roundtrips required for individual OCI datatype mapping and manipulation functions, refer to Appendix E, "OCI Function Server Roundtrips".

Examples

For more information about these functions, including some code examples, refer to Chapter 9, "Object-Relational Datatypes".

OCI Datatype Mapping Functions Quick Reference

This section is intended to help you figure out which function you need to use in a given situation.

Table 15-2 OCI Datatype Mapping and Manipulation Functions Quick Reference
Function   Purpose   Page  

 

COLLECTION ITERATOR FUNCTIONS  

 

OCICollAppend()  

Collection append element  

15 - 8  

OCICollAssignElem()  

Collection assign element  

15 - 10  

OCICollAssign()  

Assign collection  

15 - 9  

OCICollSize()  

get current size of collection (in number of elements)  

15 - 14  

OCICollTrim()  

trim elements from the collection  

15 - 16  

OCICollGetElem()  

get pointer to an element  

15 - 11  

OCICollMax()  

return maximum number of elements in collection  

15 - 13  

OCIIterCreate()  

Create ITerator to scan the varray elements  

15 - 33  

OCIIterGetCurrent()  

get CURrent collection element  

15 - 35  

OCIIterDelete()  

Delete ITerator  

15 - 34  

OCIIterInit()  

Initialize ITerator to scan the given collection  

15 - 36  

OCIIterNext()  

get NeXT collection element  

15 - 37  

OCIIterPrev()  

get PReVious collection element,  

15 - 38  

 

 

 

 

DATE FUNCTIONS  

 

OCIDateToText()  

convert date TO String  

15 - 31  

OCIDateAddDays()  

ADd or subtract Days  

15 - 17  

OCIDateAddMonths()  

ADd or subtract Months  

15 - 18  

OCIDateDaysBetween()  

get number of days BeTWeen two dates  

15 - 22  

OCIDateCheck()  

CHecK if the given date is valid  

15 - 20  

OCIDateCompare()  

CoMPare dates  

15 - 21  

OCIDateLastDay()  

get date of LaST day of month  

15 - 26  

OCIDateNextDay()  

get date of Next DaY  

15 - 27  

OCIDateFromText ()  

convert String TO Date  

15 - 23  

OCIDateSysDate()  

get current SYStem date and time  

15 - 30  

OCIDateZoneToZone()  

convert date from one time Zone TO another Zone  

15 - 32  

OCIDateAssign()  

assign date  

15 - 19  

OCIDateGetDate()  

get the date portion of a date  

15 - 24  

OCIDateGetTime()  

get the time portion of a date  

15 - 25  

OCIDateSetDate()  

set the date portion of a date  

15 - 28  

OCIDateSetTime()  

set the time portion of a date  

15 - 29  

 

 

 

 

NUMBER FUNCTIONS  

 

OCINumberToInt()  

convert number TO Integer  

15 - 73  

OCINumberToReal()  

convert number TO Real  

15 - 74  

OCINumberToText()  

convert number TO String  

15 - 75  

OCINumberAbs()  

ABSolute value  

15 - 39  

OCINumberArcCos()  

Arc COSine  

15 - 41  

OCINumberAdd()  

ADD numbers  

15 - 40  

OCINumberAssign()  

ASsiGn number  

15 - 45  

OCINumberArcSin ()  

Arc SINe  

15 - 42  

OCINumberArcTan()  

Arc TANgent  

15 - 43  

OCINumberArcTan2()  

Arc TaNgent 2  

15 - 44  

OCINumberExp()  

arbitrary Base EXponentiation  

15 - 65  

OCINumberCeil()  

CEiling of number  

15 - 55  

OCINumberCmp()  

CoMPare numbers  

15 - 47  

OCINumberCos()  

COSine  

15 - 48  

OCINumberHypCos()  

CoSine Hyperbolic  

15 - 55  

OCINumberDiv()  

DIVide numbers  

15 - 49  

OCINumberPower()  

EXPonentiation to base e  

15 - 65  

OCINumberFloor()  

FLooR of number  

15 - 51  

OCINumberFromInt()  

convert Integer TO Number  

15 - 52  

OCINumberIsZero()  

comparison with ZERo  

15 - 59  

OCINumberLn()  

Logarithm Natural  

15 - 60  

OCINumberLog ()  

LOGarithm to arbitrary base  

15 - 61  

OCINumberMod()  

MODulo division  

15 - 62  

OCINumberMul()  

MULtiply numbers  

15 - 63  

OCINumberNeg()  

NEGate number  

15 - 64  

OCINumberIntPower()  

take an arbitrary base to an arbitrary integer PoWeR  

15 - 50  

OCINumberFromReal()  

convert Real TO Number  

15 - 53  

OCINumberRound()  

ROUnd Oracle number to a specified decimal place  

15 - 66  

OCINumberSetZero()  

INItialize number to zero  

15 - 67  

OCINumberFromText()  

convert String TO Number  

15 - 54  

OCINumberSign()  

obtains SiGN of an Oracle number  

15 - 68  

OCINumberSin()  

SINe  

15 - 69  

OCINumberHypSin()  

SiNe Hyperbolic  

15 - 56  

OCINumberSqrt()  

SQuare Root of number  

15 - 70  

OCINumberSub()  

SUBtract numbers  

15 - 71  

OCINumberTan()  

tANgent  

15 - 72  

OCINumberHypTan()  

TaNgent Hyperbolic  

15 - 57  

OCINumberTrunc()  

TRUncate an Oracle number at a specified decimal place  

15 - 76  

 

 

 

 

REF FUNCTIONS  

 

OCIRefToHex()  

convert REF to Hexadecimal string  

15 - 89  

OCIRefAssign()  

ASsiGn one REF to another  

15 - 83  

OCIRefClear()  

CLeaR or nullify a REF  

15 - 84  

OCIRefIsEqual()  

compare two REFs for EQUality  

15 - 87  

OCIRefFromHex()  

convert Hexadecimal string to REF  

15 - 85  

OCIRefHexSize()  

return size of hexadecimal representation  

15 - 86  

OCIRefIsNull()  

test if a REF is NULl  

15 - 88  

 

 

 

 

TABLE FUNCTIONS  

 

OCITableDelete()  

DELete element  

15 - 96  

OCITableExists()  

Test whether element EXIsts  

15 - 97  

OCITableFirst()  

return FirST index of table  

15 - 98  

OCITableLast()  

return LaST index of table  

15 - 99  

OCITableNext()  

return NeXT available index of table  

15 - 100  

OCITablePrev()  

return PReVious available index of table  

15 - 101  

OCITableSize()  

return current size of table  

15 - 102  

 

 

 

 

STRING FUNCTIONS  

 

OCIStringAssign()  

Assign String to String  

15 - 91  

OCIStringAllocSize()  

get Allocated SiZe of string memory in bytes  

15 - 90  

OCIStringAssignText()  

Assign Text string to String  

15 - 92  

OCIStringPtr()  

Get String Pointer  

15 - 93  

OCIStringSize()  

Get String siZe  

15 - 95  

OCIStringResize()  

ReSiZe string memory  

15 - 94  

 

 

 

 

RAW FUNCTIONS  

 

OCIRawAssignBytes()  

Assign raw Bytes to Raw  

15 - 78  

OCIRawAssignRaw()  

Assign Raw to Raw  

15 - 79  

OCIRawAllocSize()  

Get Allocated SiZe of raw memory in bytes  

15 - 77  

OCIRawPtr()  

Get Raw data Pointer  

15 - 80  

OCIRawSize()  

Get Raw siZe  

15 - 82  

OCIRawResize()  

ReSiZe memory of variable-length raw  

15 - 81  

The OCI Datatype Mapping and Manipulation Functions

This chapter describes the OCI datatype mapping and manipulation functions. The entries for each function contain the following information:

Purpose

A brief statement of the purpose of the function.

Syntax

A code snippet showing the syntax for calling the function, including the ordering and types of the parameters.

Comments

Detailed information about the function (if available). This may include restrictions on the use of the function, or other information that might be useful when using the function in an application.

Parameters

A description of each of the function's parameters. This includes the parameter's mode. The mode of a parameter has three possible values, as described in Table 15-3

Table 15-3 Parameter Modes
Mode   Description  

IN  

A parameter that passes data to Oracle  

OUT  

A parameter that receives data from Oracle on this or a subsequent call  

IN/OUT  

A parameter that passes data on the call and receives data on the return from this or a subsequent call.  

:

Returns

A description of what value is returned by the function if the function returns something other than the standard return codes listed in Table 15-1.

Related Functions

A list of related functions.

OCICollAppend()

Purpose

Appends an element to a collection

Syntax

sword OCICollAppend ( OCIEnv              *env,
                      OCIError            *err,
                      CONST dvoid         *elem, 
                      CONST dvoid         *elemind,
                      OCIColl             *coll );

Parameters

env (IN/OUT) - The OCI environment handle initialized in object mode. See the description of OCIEnvInit() in Chapter 13 for more information.

err (IN/OUT) - The OCI error handle. If there is an error, it is recorded in err and this function returns OCI_ERROR. Diagnostic information can be obtained by calling OCIErrorGet().

elem (IN) - pointer to the element which is appended to the end of the given collection.

elemind (IN) [optional] - pointer to the element's null indicator information; if (elemind == NULL) then the null indicator information of the appended element will be set to non-null.

coll (IN/OUT) - updated collection.

Comments

Appends the given element to the end of the given collection.

Appending an element is equivalent to:

Note that the pointer to the given element elem will not be saved by this function. So elem is strictly an input parameter. This function returns an error if the current size of the collection is equal to the max size (upper-bound) of the collection prior to appending the element.

This function returns an error if any of the input parameters is NULL.

Related Functions

OCIErrorGet()

OCICollAssign()

Purpose

Assigns (deep-copies) one collection to another

Syntax

sword OCICollAssign ( OCIEnv              *env, 
                      OCIError            *err, 
                      CONST OCIColl       *rhs, 
                      OCIColl             *lhs );

Parameters

env (IN/OUT) - The OCI environment handle initialized in object mode. See the description of OCIEnvInit() in Chapter 13 for more information.

err (IN/OUT) - The OCI error handle. If there is an error, it is recorded in err and this function returns OCI_ERROR. Diagnostic information can be obtained by calling OCIErrorGet().

rhs (IN) - right-hand side (source) collection to be assigned from.

lhs (OUT) -left-hand side (target) collection to be assigned to.

Comments

Assigns rhs (source) to lhs (target). The lhs collection may be decreased or increased depending upon the size of rhs. If the lhs contains any elements then the elements will be deleted prior to the assignment. This function performs a deep copy. The memory for the elements comes from the object cache.

An error is returned if the element types of the lhs and rhs collections do not match. Also, an error is returned if the upper-bound of the lhs collection is less than the current number of elements in the rhs collection.

This function returns an error if:

Related Functions

OCIErrorGet()

OCICollAssignElem()

Purpose

Assign an element to a collection

Syntax

sword OCICollAssignElem ( OCIEnv           *env, 
                          OCIError         *err, 
                          sb4              index, 
                          CONST dvoid      *elem, 
                          CONST dvoid      *elemind, 
                          OCIColl          *coll );

Parameters

env (IN/OUT) - The OCI environment handle initialized in object mode. See the description of OCIEnvInit() in Chapter 13 for more information.

err (IN/OUT) - The OCI error handle. If there is an error, it is recorded in err and this function returns OCI_ERROR. Diagnostic information can be obtained by calling OCIErrorGet().

index (IN) - index of the element whose is assigned to.

elem (IN) - element which is assigned from (source element).

elemind (IN) [optional] - pointer to the element's null indicator information; if (elemind == NULL) then the null indicator information of the assigned element will be set to non-null.

coll (IN/OUT) - collection to be updated.

Comments

Assigns the given element value elem to the element at coll[index].

If the collection is of type nested table, the element at the given index may not exist (i.e. may have been deleted). In this case, the given element is inserted at index index. Otherwise, the element at index index is updated with the value of elem.

Note that the given element is deep-copied and elem is strictly an input parameter.

This function returns an error if any input parameter is NULL or if the given index is beyond the bounds of the given collection.

Related Functions

OCIErrorGet()

OCICollGetElem()

Purpose

Gets a pointer to the element at the given index

Syntax

sword OCICollGetElem ( OCIEnv           *env, 
                       OCIError         *err, 
                       CONST OCIColl    *coll, 
                       sb4              index, 
                       boolean          *exists, 
                       dvoid            **elem, 
                       dvoid            **elemind );

Parameters

env (IN/OUT) - The OCI environment handle initialized in object mode. See the description of OCIEnvInit() in Chapter 13 for more information.

err (IN/OUT) - The OCI error handle. If there is an error, it is recorded in err and this function returns OCI_ERROR. Diagnostic information can be obtained by calling OCIErrorGet().

coll (IN) - pointer to the element in this collection is returned.

index (IN) - index of the element whose pointer is returned.

exists (OUT) - set to FALSE if the element at the specified index does not exist; otherwise, set to TRUE.

elem (OUT) - address of the desired element is returned.

elemind (OUT) [optional] - address of the null indicator information is returned; if (elemind == NULL) then the null indicator information will NOT be returned.

Comments

Gets the address of the element at the given position. Optionally this function also returns the address of the element's null indicator information.

The following table describes for each collection element type what the corresponding element pointer type is. The element pointer is returned via the elem parameter of OCICollGetElem().

Element Type   *elem is set to  

Oracle Number (OCINumber)  

OCINumber*  

Date (OCIDate)  

OCIDate*  

Variable-length string (OCIString*)  

OCIString**  

Variable-length raw (OCIRaw*)  

OCIRaw**  

object reference (OCIRef*)  

OCIRef**  

lob locator (OCILobLocator*)  

OCILobLocator**  

object type (e.g. person)  

person*  

The element pointer returned by OCICollGetElem() is in a form such that it can not only be used to access the element data but also is in a form that can be used as the target (i.e., left-hand-side) of an assignment statement.

For example, assume the user is iterating over the elements of a collection whose element type is object reference (OCIRef*). A call to OCICollGetElem() returns pointer to a reference handle (i.e. OCIRef**). After getting, the pointer to the collection element, the user may wish to modify it by assigning a new reference.

This can be accomplished via the ref assignment function shown below:

sword OCIRefAssign( OCIEnv *env, OCIError *err, CONST OCIRef *source, 
OCIRef **target );

Note that the target parameter of OCIRefAssign() is of type OCIRef**. Hence OCICollGetElem() returns OCIRef**. If *target equals NULL, a new REF will be allocated by OCIRefAssign() and returned via the target parameter.

Similarly, if the collection element was of type string (OCIString*), OCICollGetElem() returns pointer to string handle (i.e. OCIString**). If a new string is assigned, via OCIStringAssign() or OCIStringAssignText() the type of the target must be OCIString **.

If the collection element is of type Oracle number, OCICollGetElem() returns OCINumber*. The prototype of OCINumberAssign() is shown below:

sword OCINumberAssign(OCIError *err, CONST OCINumber *from,
OCINumber *to);

This function returns an error if any of the input parameters is NULL.

Related Functions

OCIErrorGet()

OCICollMax()

Purpose

Gets the maximum size (in number of elements) of the given collection

Syntax

sb4 OCICollMax ( OCIEnv           *env,
                 CONST OCIColl    *coll );

Parameters

env (IN/OUT) - The OCI environment handle initialized in object mode. See the description of OCIEnvInit() in Chapter 13 for more information.

coll (IN) - collection whose number of elements is returned. coll must point to a valid collection descriptor.

Comments

Returns the maximum number of elements that the given collection can hold. A value of zero indicates that the collection has no upper bound.

Returns

the upper bound of the given collection

Related Functions

OCIErrorGet()

OCICollSize()

Purpose

Gets the current size (in number of elements) of the given collection

Syntax

sword OCICollSize ( OCIEnv           *env,
                    OCIError         *err,
                    CONST OCIColl    *coll 
                    sb4              *size );

Parameters

env (IN/OUT) - The OCI environment handle initialized in object mode. See the description of OCIEnvInit() in Chapter 13 for more information.

err (IN/OUT) - The OCI error handle. If there is an error, it is recorded in err and this function returns OCI_ERROR. Diagnostic information can be obtained by calling OCIErrorGet().

coll (IN) - collection whose number of elements is returned. Must point to a valid collection descriptor.

size (OUT) - current number of elements in the collection.

Comments

Returns the current number of elements in the given collection.

For the case of nested table, this count will NOT be decremented upon deleting elements. So, this count includes any "holes" created by deleting elements. A trim operation (OCICollTrim()) will decrement the count by the number of trimmed elements. To get the count minus the deleted elements use OCITableSize().

The following pseudocode shows some examples:

OCICollSize(...); 
// assume 'size' returned is equal to 5
OCITableDelete(...); // delete one element
OCICollSize(...);
// 'size' returned is still 5

To get the count minus the deleted elements use OCITableSize(). Continuing the above example:

OCITableSize(...)
// 'size' returned is equal to 4

A trim operation (OCICollTrim()) decrements the count by the number of trimmed elements. Continuing the above example:

OCICollTrim(..,1..); // trim one element
OCICollSize(...);
// 'size' returned is equal to 4

This function returns an error if an error occurs during the loading of the collection into object cache or if any of the input parameters is null.

Related Functions

OCIErrorGet()

OCICollTrim()

Purpose

Trims the given number of elements from the end of the collection

Syntax

sword OCICollTrim ( OCIEnv         *env, 
                    OCIError       *err, 
                    sb4            trim_num, 
                    OCIColl        *coll );

Parameters

env (IN/OUT) - The OCI environment handle initialized in object mode. See the description of OCIEnvInit() in Chapter 13 for more information.

err (IN/OUT) - The OCI error handle. If there is an error, it is recorded in err and this function returns OCI_ERROR. Diagnostic information can be obtained by calling OCIErrorGet().

trim_num (IN) - number of elements to trim.

coll (IN/OUT) - trim_num elements are removed (freed) from the end of coll by this function.

Comments

Trim the collection by the given number of elements. The elements are removed from the end of the collection. An error is returned if trim_num is greater than the current size of the collection.

This function returns an error if trim_num is greater than the current size of the collection.

Related Functions

OCIErrorGet()

OCIDateAddDays()

Purpose

Adds or subtracts days from a given date.

Syntax

sword OCIDateAddDays ( OCIError          *err,
                       CONST OCIDate     *date, 
                       sb4               num_days,
                       OCIDate           *result );

Parameters

err (IN/OUT) -The OCI error handle. If there is an error, it is recorded in err and this function returns OCI_ERROR. Diagnostic information can be obtained by calling OCIErrorGet().

date (IN) - num_days added or subtracted from date.

num_days (IN) - number of days to be added or subtracted (a negative value will be subtracted).

result (IN/OUT) - result of adding days to, or subtracting days from, date.

Comments

Adds or subtracts num_days from the date date.

This function returns and error if an invalid date is passed to it.

Related Functions

OCIErrorGet()

OCIDateAddMonths()

Purpose

Adds or subtracts months from a given date.

Syntax

sword OCIDateAddMonths ( OCIError            *err,
                         CONST OCIDate       *date,
                         sb4                 num_months,
                         OCIDate             *result );

Parameters

err (IN/OUT) - The OCI error handle. If there is an error, it is recorded in err and this function returns OCI_ERROR. Diagnostic information can be obtained by calling OCIErrorGet().

date (IN) - num_months added or subtracted from date.

num_months (IN) - number of months to be added or subtracted (a negative value is subtracted).

result (IN/OUT) - result of adding days to, or subtracting days from, date.

Comments

Adds or subtracts num_months from the date date.

If the input date is the last day of a month, then the appropriate adjustments are made to ensure that the output date is also the last day of the month. For example, Feb. 28 + 1 month = March 31, and November 30 - 3 months = August 31. Otherwise the result date has the same day component as date.

This function returns an error if invalid date is passed to it.

Related Functions

OCIErrorGet()

OCIDateAssign()

Purpose

Performs date assignment

Syntax

sword OCIDateAssign ( OCIError         *err,
                      CONST OCIDate    *from, 
                      OCIDate          *to );

Parameters

err (IN/OUT) - The OCI error handle. If there is an error, it is recorded in err and this function returns OCI_ERROR. Diagnostic information can be obtained by calling OCIErrorGet().

from (IN) - date to be assigned.

to (OUT) - target of assignment.

Comments

This function assigns a value from one OCIDate variable to another.

Related Functions

OCIErrorGet()

OCIDateCheck()

Purpose

Checks if the given date is valid.

Syntax

sword OCIDateCheck ( OCIError          *err,
                     CONST OCIDate     *date, 
                     uword             *valid );

Parameters

err (IN/OUT) - The OCI error handle. If there is an error, it is recorded in err and this function returns OCI_ERROR. Diagnostic information can be obtained by calling OCIErrorGet().

date (IN) - date to be checked

valid (OUT) - returns zero for a valid date, otherwise the ORed combination of all error bits specified below:

Macro name Bit number Error---------- ---------- -----------------------------OCI_DATE_INVALID_DAY 0x1 Bad dayOCI_DATE_DAY_BELOW_VALID 0x2 Bad day low/high bit (1=low)OCI_DATE_INVALID_MONTH 0x4 Bad monthOCI_DATE_MONTH_BELOW_VALID 0x8 Bad month low/high bit (1=low)OCI_DATE_INVALID_YEAR 0x10 Bad yearOCI_DATE_YEAR_BELOW_VALID 0x20 Bad year low/high bit (1=low)OCI_DATE_INVALID_HOUR 0x40 Bad hourOCI_DATE_HOUR_BELOW_VALID 0x80 Bad hour low/high bit (1=low)OCI_DATE_INVALID_MINUTE 0x100 Bad minuteOCI_DATE_MINUTE_BELOW_VALID 0x200 Bad minute Low/high bit (1=low)OCI_DATE_INVALID_SECOND 0x400 Bad secondOCI_DATE_SECOND_BELOW_VALID 0x800 Bad second Low/high bit (1=low)OCI_DATE_DAY_MISSING_FROM_1582 0x1000 Day is one of those "missing" from 1582OCI_DATE_YEAR_ZERO 0x2000 Year may not equal zeroOCI_DATE_INVALID_FORMAT 0x8000 Bad date format input

So, for example, if the date passed in was 2/0/1990 25:61:10 in (month/day/year hours:minutes:seconds format), the error returned would be OCI_DATE_INVALID_DAY | OCI_DATE_DAY_BELOW_VALID | OCI_DATE_INVALID_HOUR | OCI_DATE_INVALID_MINUTE

Comments

Checks if the given date is valid.

This function returns an error if date or valid pointer is NULL.

Related Functions

OCIErrorGet()

OCIDateCompare()

Purpose

Compares two dates.

Syntax

sword OCIDateCompare ( OCIError           *err, 
                       CONST OCIDate      *date1, 
                       CONST OCIDate      *date2,
                       sword              *result );

Parameters

err (IN/OUT) -The OCI error handle. If there is an error, it is recorded in err and this function returns OCI_ERROR. Diagnostic information can be obtained by calling OCIErrorGet().

date1, date2 (IN) - dates to be compared.

result (OUT) - comparison result:

Comparison result   Output in result parameter  

date1 < date2  

-1  

date1 = date2  

0  

date1 > date2  

1  

Comments

Compares two dates.

This function returns and error if an invalid date is passed to it.

Related Functions

OCIErrorGet()

OCIDateDaysBetween()

Purpose

Gets the number of days between two dates

Syntax

sword OCIDateDaysBetween ( OCIError            *err, 
                           CONST OCIDate       *date1, 
                           CONST OCIDate       *date2, 
                           sb4                 *num_days );

Parameters

err (IN/OUT) - The OCI error handle. If there is an error, it is recorded in err and this function returns OCI_ERROR. Diagnostic information can be obtained by calling OCIErrorGet().

date1, date2 (IN) - input dates.

num_days (OUT) - number of days between date1 and date2.

Comments

Returns the number of days between date1 and date2. The time is ignored in this computation.

This function returns an error if invalid date is passed to it.

Related Functions

OCIErrorGet()

OCIDateFromText()

Purpose

Converts a character string to a date type.

Syntax

sword OCIDateFromText ( OCIError           *err,
                        CONST text         *date_str, 
                        ub4                d_str_length, 
                        CONST text         *fmt,
                        ub1                fmt_length, 
                        CONST text         *lang_name,
                        ub4                lang_length, 
                        OCIDate            *date );

Parameters

err (IN/OUT) - The OCI error handle. If there is an error, it is recorded in err and this function returns OCI_ERROR. Diagnostic information can be obtained by calling OCIErrorGet().

date_str (IN) - input string to be converted to Oracle date.

d_str_length (IN) - size of the input string, if the length is -1 then date_str is treated as a NULL terminated string.

fmt (IN) - conversion format. If fmt is a null pointer, then the string is expected to be in `DD-MON-YY' format.

fmt_length (IN) - length of the fmt parameter.

lang_name (IN) - language in which the names and abbreviations of days and months are specified. If lang_name is a NULL string, (text *) 0, then the default language of the session is used.

lang_length (IN) - length of the lang_name parameter.

date (OUT) - given string converted to date.

Comments

Converts the given string to Oracle date according to the specified format.

Refer to the TO_DATE conversion function described in Chapter 3 of the Oracle SQL Language Reference for a description of format and NLS arguments.

This function returns an error if it receives an invalid format, language, or input string.

Related Functions

OCIErrorGet()

OCIDateGetDate()

Purpose

Get the year, month, and day stored in an Oracle date.

Syntax

void OCIDateGetDate ( CONST OCIDate    *date,
                      sb2              *year,
                      ub1              *month, 
                      ub1              *day ); 

Parameters

date (IN) - Oracle date whose year, month, day data is retrieved.

year (OUT) - year value returned.

month (OUT) - month value returned.

day (OUT) - day value returned.

Comments

Returns year, month, day information stored in the given date.

Related Functions

OCIDateSetDate()

OCIDateGetTime()

Purpose

Get the time stored in an Oracle date.

Syntax

void OCIDateGetTime ( CONST OCIDate    *date,
                      ub1              *hour,
                      ub1              *min, 
                      ub1              *sec );

Parameters

date (IN) - Oracle date whose time data is retrieved.

hour (OUT) - hour value returned.

min (OUT) - minute value returned.

sec (OUT) - second value returned.

Comments

Returns time information stored in the given date. The time information returned is: hour, minute and seconds.

Related Functions

OCIDateSetTime()

OCIDateLastDay()

Purpose

Gets the date of the last day of the month.

Syntax

sword OCIDateLastDay ( OCIError            *err,
                       CONST OCIDate       *date,
                       OCIDate             *last_day );

Parameters

err (IN/OUT) - The OCI error handle. If there is an error, it is recorded in err and this function returns OCI_ERROR. Diagnostic information can be obtained by calling OCIErrorGet().

date (IN) - input date.

last_day (OUT) - last day of the month in date.

Comments

Returns the date of the last day of the month specified in date.

This function returns an error if invalid date is passed to it.

Related Functions

OCIErrorGet()

OCIDateNextDay()

Purpose

Gets the date of next day of the week, after a given date.

Syntax

sword OCIDateNextDay ( OCIError            *err,
                       CONST OCIDate       *date,
                       CONST text          *day, 
                       ub4                 day_length,
                       OCIDate             *next_day );

Parameters

err (IN/OUT) -The OCI error handle. If there is an error, it is recorded in err and this function returns OCI_ERROR. Diagnostic information can be obtained by calling OCIErrorGet().

date (IN) - returned date should be later than this date.

day (IN) - first day of week named by this is returned.

day_length (IN) - length in bytes of string day.

next_day (OUT) - first day of the week named by day later than date.

Comments

Returns the date of the first day of the week named by day that is later than date date.

Example: Get the date of the next Monday after April 18, 1996 (a Thursday).

OCIDateNextDay(&err, `18-APR-96', `MONDAY', strlen(`MONDAY'), &next_day)

OCIDateNextDay() will return `22-APR-96'.

This function returns and error if an invalid date or day is passed to it.

Related Functions

OCIErrorGet()

OCIDateSetDate()

Purpose

Set the values in an Oracle date.

Syntax

void OCIDateSetDate ( OCIDate    *date, 
                      sb2        year, 
                      ub1        month, 
                      ub1        day );

Parameters

date (OUT) - Oracle date whose time data is set.

year (IN) - year value to be set.

month (IN) - month value to be set.

day (IN) - day value to be set.

Comments

Sets the date with the given information.

Related Functions

OCIDateGetDate()

OCIDateSetTime()

Purpose

Set the time information in an Oracle date.

Syntax

void OCIDateSetTime ( OCIDate    *date,
                      ub1        hour, 
                      ub1        min, 
                      ub1        sec ); 

Parameters

date (OUT) - Oracle date whose time data is set.

hour (IN) - hour value to be set.

min (IN) - minute value to be set.

sec (IN) - second value to be set.

Comments

Sets the date with the given time information.

Related Functions

OCIDateGetTime()

OCIDateSysDate()

Purpose

Gets current system date and time.

Syntax

sword OCIDateSysDate ( OCIError       *err,
                       OCIDate        *sys_date );

Parameters

err (IN/OUT) -The OCI error handle. If there is an error, it is recorded in err and this function returns OCI_ERROR. Diagnostic information can be obtained by calling OCIErrorGet().

sys_date (OUT) - current system date and time.

Comments

Returns the current system date and time.

Related Functions

OCIErrorGet()

OCIDateToText()

Purpose

Converts a date type to a character string.

Syntax

sword OCIDateToText ( OCIError           *err, 
                      CONST OCIDate      *date, 
                      CONST text         *fmt, 
                      ub1                fmt_length, 
                      CONST text         *lang_name,
                      ub4                lang_length, 
                      ub4                *buf_size, 
                      text               *buf );

Parameters

err (IN/OUT) -The OCI error handle. If there is an error, it is recorded in err and this function returns OCI_ERROR. Diagnostic information can be obtained by calling OCIErrorGet().

date (IN) - Oracle date to be converted.

fmt (IN) - conversion format, if NULL string pointer, (text *) 0, then the date is converted to a character string in the default date format, "DD-MON-YY".

fmt_length (IN) - length of the fmt parameter.

lang_name (IN) - specifies the language in which the names and abbreviations of months and days are returned; default language of session is used if lang_name is NULL, (text *) 0.

lang_length (IN) - length of the lang_name parameter.

buf_size (IN/OUT) - size of the buffer (IN); size of the resulting string is returned via this parameter(OUT).

buf (OUT) - buffer into which the converted string is placed.

Comments

Converts the given date to a string according to the specified format. The converted NULL-terminated date string is stored in buf.

Refer to the TO_DATE conversion function described in Chapter 3 of the Oracle SQL Language Reference for a description of format and NLS arguments.

This function returns an error if the buffer is too small, or if the function is passed an invalid format or unknown language. Overflow also causes an error. For example, converting a value of 10 into format '9' causes an error.

Related Functions

OCIErrorGet()

OCIDateZoneToZone()

Purpose

Converts a date from one time zone to another.

Syntax

sword OCIDateZoneToZone ( OCIError           *err, 
                          CONST OCIDate      *date1, 
                          CONST text         *zon1,
                          ub4                zon1_length, 
                          CONST text         *zon2, 
                          ub4                zon2_length, 
                          OCIDate            *date2 );

Parameters

err (IN/OUT) - The OCI error handle. If there is an error, it is recorded in err and this function returns OCI_ERROR. Diagnostic information can be obtained by calling OCIErrorGet().

date1 (IN) - date to be converted.

zon1 (IN) - zone of input date.

zon1_length (IN) - length in bytes of zon1.

zon2 (IN) - zone to be converted to.

zon2_length (IN) - length in bytes of zon2.

date2 (OUT) - converted date (in zon2).

Comments

Converts date from one time zone to another. Given date date1 in time zone zon1, returns date date2 in time zone zon2.

For a list of valid zone strings, refer to the description of the "NEW_TIME" function in Chapter 3 of the Oracle8 Server SQL Reference. Examples of valid zone strings include:

"AST", Atlantic Standard Time

"ADT", Atlantic Daylight Time

"BST", Bering Standard Time

"BDT", Bering Daylight Time

This function returns and error if an invalid date or time zone is passed to it.

Related Functions

OCIErrorGet()

OCIIterCreate()

Purpose

Creates an iterator to scan collection elements.

Syntax

sword OCIIterCreate ( OCIEnv               *env, 
                      OCIError             *err, 
                      CONST OCIColl        *coll, 
                      OCIIter              **itr );

Parameters

env (IN/OUT) - The OCI environment handle initialized in object mode. See the description of OCIEnvInit() in Chapter 13 for more information.

err (IN/OUT) - The OCI error handle. If there is an error, it is recorded in err and this function returns OCI_ERROR. Diagnostic information can be obtained by calling OCIErrorGet().

coll (IN) - collection which will be scanned. For release 8.0, valid collection types include varrays and nested tables.

itr (OUT) - address to the allocated collection iterator is returned by this function.

Comments

Creates an iterator to scan the elements of the collection. The iterator is created in the object cache. The iterator is initialized to point to the beginning of the collection.

If OCIIterNext() is called immediately after creating the iterator then the first element of the collection is returned. If OCIIterPrev() is called immediately after creating the iterator then "at beginning of collection" error is returned.

This function returns an error if any of the input parameters is NULL.

Related Functions

OCIErrorGet(), OCIIterDelete()

OCIIterDelete()

Purpose

Deletes a collection iterator.

Syntax

sword OCIIterDelete ( OCIEnv           *env, 
                      OCIError         *err, 
                      OCIIter          **itr );

Parameters

env (IN/OUT) - The OCI environment handle initialized in object mode. See the description of OCIEnvInit() in Chapter 13 for more information.

err (IN/OUT) - The OCI error handle. If there is an error, it is recorded in err and this function returns OCI_ERROR. Diagnostic information can be obtained by calling OCIErrorGet().

itr (IN/OUT) - the allocated collection iterator which is destroyed and set to NULL prior to returning.

Comments

Deletes an iterator which was previously created by a call to OCIIterCreate().

This function returns an error if any of the input parameters is null.

Related Functions

OCIErrorGet(), OCIIterCreate()

OCIIterGetCurrent()

Purpose

Gets a pointer to the current iterator collection element.

Syntax

sword OCIIterGetCurrent ( OCIEnv            *env, 
                          OCIError          *err, 
                          CONST OCIIter     *itr, 
                          dvoid             **elem, 
                          dvoid             **elemind );

Parameters

env (IN/OUT) - The OCI environment handle initialized in object mode. See the description of OCIEnvInit() in Chapter 13 for more information.

err (IN/OUT) - The OCI error handle. If there is an error, it is recorded in err and this function returns OCI_ERROR. Diagnostic information can be obtained by calling OCIErrorGet().

itr (IN) - iterator which points to the current element.

elem (OUT) - address of the element pointed by the iterator is returned.

elemind (OUT) [optional] - address of the element's NULL indicator information is returned; if (elem_ind == NULL) then the NULL indicator information will not be returned.

Comments

Returns pointer to the current iterator collection element and its corresponding NULL information.

This function returns an error if any input parameter is NULL.

Related Functions

OCIErrorGet()

OCIIterInit()

Purpose

Initializes an iterator to scan a collection.

Syntax

sword OCIIterInit ( OCIEnv              *env, 
                    OCIError            *err, 
                    CONST OCIColl       *coll, 
                    OCIIter             *itr );

Parameters

env (IN/OUT) - The OCI environment handle initialized in object mode. See the description of OCIEnvInit() in Chapter 13 for more information.

err (IN/OUT) - The OCI error handle. If there is an error, it is recorded in err and this function returns OCI_ERROR. Diagnostic information can be obtained by calling OCIErrorGet().

coll (IN) - collection which will be scanned. For release 8.0, valid collection types include varrays and nested tables.

itr (IN/OUT) - pointer to an allocated collection iterator.

Comments

Initializes the given iterator to point to the beginning of the given collection. This function can be used to:

This function returns an error if any input parameter is NULL.

Related Functions

OCIErrorGet()

OCIIterNext()

Purpose

Gets a pointer to the next iterator collection element.

Syntax

sword OCIIterNext ( OCIEnv            *env,
                    OCIError          *err, 
                    OCIIter           *itr, 
                    dvoid             **elem,
                    dvoid             **elemind,
                    boolean           *eoc);

Parameters

env (IN/OUT) - The OCI environment handle initialized in object mode. See the description of OCIEnvInit() in Chapter 13 for more information.

err (IN/OUT) - The OCI error handle. If there is an error, it is recorded in err and this function returns OCI_ERROR. Diagnostic information can be obtained by calling OCIErrorGet().

itr (IN/OUT) - iterator is updated to point to the next element.

elem (OUT) - after updating the iterator to point to the next element, address of the element is returned.

elemind (OUT) [optional] - address of the element's NULL indicator information is returned; if (elem_ind == NULL) then the NULL indicator information will not be returned.

eoc (OUT) - TRUE if iterator is at End of Collection (i.e. next element does not exist); otherwise, FALSE.

Comments

Returns a pointer to the next iterator collection element and its corresponding NULL information. Updates the iterator to point to the next element.

If the iterator is pointing to the last element of the collection prior to executing this function, then calling this function will set the eoc flag to TRUE. The iterator will be left unchanged in that case.

This function returns an error if any input parameter is NULL.

Related Functions

OCIErrorGet(), OCIIterPrev()

OCIIterPrev()

Purpose

Gets a pointer to the previous iterator collection element

Syntax

sword OCIIterPrev ( OCIEnv            *env, 
                    OCIError          *err, 
                    OCIIter           *itr, 
                    dvoid             **elem, 
                    dvoid             **elemind,
                    boolean           *boc );

Parameters

env (IN/OUT) - The OCI environment handle initialized in object mode. See the description of OCIEnvInit() in Chapter 13 for more information.

err (IN/OUT) - The OCI error handle. If there is an error, it is recorded in err and this function returns OCI_ERROR. Diagnostic information can be obtained by calling OCIErrorGet().

itr (IN/OUT) - iterator which is updated to point to the previous element.

elem (OUT) - address of the previous element; returned after the iterator is updated to point to it.

elemind (OUT) [optional] - address of the element's NULL indicator; if (elem_ind == NULL) then the NULL indicator will not be returned.

boc (OUT) - TRUE if iterator is at Beginning of Collection (i.e. previous element does not exist); otherwise, FALSE.

Comments

Returns pointer to the previous iterator collection element and its corresponding NULL information. The iterator is updated to point to the previous element.

If the iterator is pointing to the first element of the collection prior to executing this function, then calling this function will set boc to TRUE. The iterator is left unchanged in that case.

This function returns an error if any input parameter is NULL.

Related Functions

OCIErrorGet(), OCIIterNext()

OCINumberAbs()

Purpose

Computes the absolute value of an Oracle number.

Syntax

sword OCINumberAbs ( OCIError              *err,
                     CONST OCINumber       *number, 
                     OCINumber             *result );

Parameters

err (IN/OUT) - The OCI error handle. If there is an error, it is recorded in err and this function returns OCI_ERROR. Diagnostic information can be obtained by calling OCIErrorGet().

number (IN) - input number.

result (OUT) - the absolute value of the input number.

Comments

Computes the absolute value of an Oracle number.

This function returns an error if any of the number arguments is NULL.

Related Functions

OCIErrorGet()

OCINumberAdd()

Purpose

Adds two Oracle numbers together.

Syntax

sword OCINumberAdd ( OCIError              *err,
                     CONST OCINumber       *number1, 
                     CONST OCINumber       *number2,
                     OCINumber             *result );

Parameters

err (IN/OUT) -The OCI error handle. If there is an error, it is recorded in err and this function returns OCI_ERROR. Diagnostic information can be obtained by calling OCIErrorGet().

number1, number2 (IN) - numbers to be added.

result (OUT) - result of adding number1 to number2.

Comments

Adds number1 to number2 and returns result in result.

This function returns an error if any of the number arguments is NULL.

Related Functions

OCIErrorGet()

OCINumberArcCos()

Purpose

Takes the arc cosine of an Oracle number.

Syntax

sword OCINumberArcCos ( OCIError            *err, 
                        CONST OCINumber     *number, 
                        OCINumber           *result );

Parameters

err (IN/OUT) - The OCI error handle. If there is an error, it is recorded in err and this function returns OCI_ERROR. Diagnostic information can be obtained by calling OCIErrorGet().

number (IN) - argument of the arc cosine.

result (OUT) - result of the arc cosine in radians.

Comments

Takes the arc cosine in radians of an Oracle number.

This function returns an error if any of the number arguments is NULL, or if number < -1 or if number > 1.

Related Functions

OCIErrorGet()

OCINumberArcSin()

Purpose

Takes the arc sine of an Oracle number.

Syntax

sword OCINumberArcSin ( OCIError              *err,
                        CONST OCINumber       *number, 
                        OCINumber             *result );

Parameters

err (IN/OUT) - The OCI error handle. If there is an error, it is recorded in err and this function returns OCI_ERROR. Diagnostic information can be obtained by calling OCIErrorGet().

number (IN) - argument of the arc sine.

result (OUT) - result of the arc sine in radians.

Comments

Takes the arc sine in radians of an Oracle number.

This function returns an error if any of the number arguments is NULL, or if number < -1 or if number > 1.

Related Functions

OCIErrorGet()

OCINumberArcTan()

Purpose

Takes the arc tangent of an Oracle number.

Syntax

sword OCINumberArcTan ( OCIError             *err, 
                        CONST OCINumber      *number, 
                        OCINumber            *result );

Parameters

err (IN/OUT) - The OCI error handle. If there is an error, it is recorded in err and this function returns OCI_ERROR. Diagnostic information can be obtained by calling OCIErrorGet().

number (IN) - argument of the arc tangent.

result (OUT) - result of the arc tangent in radians.

Comments

Takes the arc tangent in radians of an Oracle number.

This function returns an error if any of the number arguments is NULL.

Related Functions

OCIErrorGet()

OCINumberArcTan2()

Purpose

Takes the arc tangent of two Oracle numbers.

Syntax

sword OCINumberArcTan2 ( OCIError              *err, 
                         CONST OCINumber       *number1, 
                         CONST OCINumber       *number2,
                         OCINumber             *result );

Parameters

err (IN/OUT) -The OCI error handle. If there is an error, it is recorded in err and this function returns OCI_ERROR. Diagnostic information can be obtained by calling OCIErrorGet().

number1 (IN) - argument 1 of the arc tangent.

number2 (IN) - argument 2 of the arc tangent.

result (OUT) - result of the arc tangent in radians.

Comments

Takes the atan2(number1, number2).

This function returns an error if any of the number arguments is NULL, or if number2 = 0.

Related Functions

OCIErrorGet()

OCINumberAssign()

Purpose

Assigns one Oracle number to another Oracle number.

Syntax

sword OCINumberAssign ( OCIError              *err,
                        CONST OCINumber       *from, 
                        OCINumber             *to );

Parameters

err (IN/OUT) -The OCI error handle. If there is an error, it is recorded in err and this function returns OCI_ERROR. Diagnostic information can be obtained by calling OCIErrorGet().

from (IN) - number to be assigned.

to (OUT) - number copied into.

Comments

Assigns number from to to.

This function returns an error if any of the number arguments is NULL.

Related Functions

OCIErrorGet()

OCINumberCeil()

Purpose

Computes the ceiling value of an Oracle number.

Syntax

sword OCINumberCeil ( OCIError              *err, 
                      CONST OCINumber       *number, 
                      OCINumber             *result );

Parameters

err (IN/OUT) - The OCI error handle. If there is an error, it is recorded in err and this function returns OCI_ERROR. Diagnostic information can be obtained by calling OCIErrorGet().

number (IN) - input number.

result (OUT) - output which will contain the ceiling value of the input number.

Comments

Computes the ceiling value of an Oracle number.

This function returns an error if any of the number arguments is NULL.

Related Functions

OCIErrorGet()

OCINumberCmp()

Purpose

Compares two Oracle numbers.

Syntax

sword OCINumberCmp ( OCIError            *err,
                     CONST OCINumber     *number1, 
                     CONST OCINumber     *number2,
                     sword               *result );

Parameters

err (IN/OUT) -The OCI error handle. If there is an error, it is recorded in err and this function returns OCI_ERROR. Diagnostic information can be obtained by calling OCIErrorGet().

number1, number2 (IN) - numbers to be compared.

result (OUT) - comparison result:

Comparison result   Output in result parameter  

number1 < number2  

negative  

number1 = number2  

0  

number1 > number2  

positive  

Comments

Compares two Oracle numbers.

This function returns an error if any of the number arguments is NULL.

Related Functions

OCIErrorGet()

OCINumberCos()

Purpose

Takes the cosine of an Oracle number.

Syntax

sword OCINumberCos ( OCIError              *err,
                     CONST OCINumber       *number, 
                     OCINumber             *result );

Parameters

err (IN/OUT) -The OCI error handle. If there is an error, it is recorded in err and this function returns OCI_ERROR. Diagnostic information can be obtained by calling OCIErrorGet().

number (IN) - argument of the cosine in radians.

result (OUT) - result of the cosine.

Comments

Takes the cosine in radians of an Oracle number.

This function returns an error if any of the number arguments is NULL.

Related Functions

OCIErrorGet()

OCINumberDiv()

Purpose

Divides two Oracle numbers.

Syntax

sword OCINumberDiv ( OCIError               *err,
                     CONST OCINumber        *number1, 
                     CONST OCINumber        *number2,
                     OCINumber              *result );

Parameters

err (IN/OUT) - The OCI error handle. If there is an error, it is recorded in err and this function returns OCI_ERROR. Diagnostic information can be obtained by calling OCIErrorGet().

number1 (IN) - pointer to the numerator.

number2 (IN) - pointer to the denominator.

result (OUT) - division result.

Comments

Divides number1 by number2 and returns result in result.

This function returns an error if:

Related Functions

OCIErrorGet()

OCINumberExp()

Purpose

Raises e to the specified Oracle number power.

Syntax

sword OCINumberExp ( OCIError              *err, 
                     CONST OCINumber       *number,
                     OCINumber             *result );

Parameters

err (IN/OUT) - The OCI error handle. If there is an error, it is recorded in err and this function returns OCI_ERROR. Diagnostic information can be obtained by calling OCIErrorGet().

number (IN) - e is raised to this Oracle number power.

result (OUT) - output of exponentiation.

Comments

Raises e to a given power, specified by an Oracle number.

This function returns an error if any of the number arguments is NULL.

Related Functions

OCIErrorGet()

OCINumberFloor()

Purpose

Computes the floor value of an Oracle number.

Syntax

sword OCINumberFloor ( OCIError              *err,
                       CONST OCINumber       *number, 
                       OCINumber             *result );

Parameters

err (IN/OUT) - The OCI error handle. If there is an error, it is recorded in err and this function returns OCI_ERROR. Diagnostic information can be obtained by calling OCIErrorGet().

number (IN) - input number.

result (OUT) - the floor value of the input number.

Comments

Computes the floor value of an Oracle number.

This function returns an error if any of the number arguments is NULL.

Related Functions

OCIErrorGet()

OCINumberFromInt()

Purpose

Converts integer to Oracle number.

Syntax

sword OCINumberFromInt ( OCIError            *err,
                         CONST dvoid         *inum, 
                         uword               inum_length,
                         uword               inum_s_flag,
                         OCINumber           *number );

Parameters

err (IN/OUT) -The OCI error handle. If there is an error, it is recorded in err and this function returns OCI_ERROR. Diagnostic information can be obtained by calling OCIErrorGet().

inum (IN) - pointer to the integer to be converted.

inum_length (IN) - size of the integer.

inum_s_flag (IN) - flag that designates the sign of the integer, as follows:

Predefined Constant   Use  

OCI_NUMBER_UNSIGNED  

Unsigned values  

OCI_NUMBER_SIGNED  

Signed values  

number (OUT) - given integer converted to Oracle number.

Comments

This is a native type conversion function. It converts any Oracle standard machine-native integer type (e.g. ub4, sb2) to an Oracle number.

This function returns an error if the number is too big to fit into an Oracle number, if number or inum is NULL, or if an invalid sign flag value is passed in inum_s_flag.

Related Functions

OCIErrorGet()

OCINumberFromReal()

Purpose

Converts a real (floating-point) type to an Oracle number.

Syntax

sword OCINumberFromReal ( OCIError           *err,
                          CONST dvoid        *rnum,
                          uword              rnum_length,
                          OCINumber          *number );

Parameters

err (IN/OUT) -The OCI error handle. If there is an error, it is recorded in err and this function returns OCI_ERROR. Diagnostic information can be obtained by calling OCIErrorGet().

rnum (IN) - pointer to the floating point number to be converted.

rnum_length (IN) -the size of the desired result. Will be equal to sizeof({float | double | long double}).

number (OUT) - given float converted to Oracle number.

Comments

This is a native type conversion function. It converts a machine-native floating point type to an Oracle number.

This function returns an error if number or rnum is NULL, or if rnum_length equals zero.

Related Functions

OCIErrorGet()

OCINumberFromText()

Purpose

Converts character string to Oracle number.

Syntax

sword OCINumberFromText ( OCIError           *err, 
                          CONST text         *str, 
                          ub4                str_length,
                          CONST text         *fmt,
                          ub4                fmt_length, 
                          CONST text         *nls_params, 
                          ub4                nls_p_length, 
                          OCINumber          *number );

Parameters

err (IN/OUT) -The OCI error handle. If there is an error, it is recorded in err and this function returns OCI_ERROR. Diagnostic information can be obtained by calling OCIErrorGet().

str (IN) - input string to be converted to Oracle number.

str_length (IN) - size of the input string.

fmt (IN) - conversion format.

fmt_length (IN) - length of the fmt parameter.

nls_params (IN) - NLS format specification, if NULL string ("") then the default parameters for the session is used.

nls_p_length (IN) - length of the nls_params parameter.

number (OUT) - given string converted to number.

Comments

Converts the given string to a number according to the specified format. Refer to the TO_NUMBER conversion function described in the Oracle SQL Language Reference for a description of format and NLS parameters.

This function returns an error if there is an invalid format, an invalid NLS format, or an invalid input string, if number or str is NULL, or if str_length is zero.

Related Functions

OCIErrorGet()

OCINumberHypCos()

Purpose

Takes the hyperbolic cosine of an Oracle number.

Syntax

sword OCINumberHypCos ( OCIError              *err, 
                        CONST OCINumber       *number, 
                        OCINumber             *result );

Parameters

err (IN/OUT) - The OCI error handle. If there is an error, it is recorded in err and this function returns OCI_ERROR. Diagnostic information can be obtained by calling OCIErrorGet().

number (IN) - argument of the cosine hyperbolic.

result (OUT) - result of the cosine hyperbolic.

Comments

Takes the hyperbolic cosine of an Oracle number.

This function returns an error if any of the number arguments is NULL.

Warning: An Oracle number overflow causes an unpredictable result value.

Related Functions

OCIErrorGet()

OCINumberHypSin()

Purpose

Takes the hyperbolic sine of an Oracle number.

Syntax

sword OCINumberHypSin ( OCIError              *err,
                        CONST OCINumber       *number, 
                        OCINumber             *result );

Parameters

err (IN/OUT) - The OCI error handle. If there is an error, it is recorded in err and this function returns OCI_ERROR. Diagnostic information can be obtained by calling OCIErrorGet().

number (IN) - argument of the sine hyperbolic.

result (OUT) - result of the sine hyperbolic.

Comments

Takes the hyperbolic sine of an Oracle number.

This function returns an error if any of the number arguments is NULL.

Warning: An Oracle number overflow causes an unpredictable result value.

Related Functions

OCIErrorGet(), OCINumberHypCos(), OCINumberHypTan()

OCINumberHypTan()

Purpose

Takes the hyperbolic tangent of an Oracle number.

Syntax

sword OCINumberHypTan ( OCIError              *err,
                        CONST OCINumber       *number,
                        OCINumber             *result );

Parameters

err (IN/OUT) -The OCI error handle. If there is an error, it is recorded in err and this function returns OCI_ERROR. Diagnostic information can be obtained by calling OCIErrorGet().

number (IN) - argument of the tangent hyperbolic.

result (OUT) - result of the tangent hyperbolic.

Comments

Takes the hyperbolic tangent of an Oracle number.

This function returns an error if any of the number arguments is NULL.

Warning: An Oracle number overflow causes an unpredictable result value.

Related Functions

OCIErrorGet(), OCINumberHypCos(), OCINumberHypSin()

OCINumberIntPower()

Purpose

Raises a given base to a given integer power.

Syntax

sword OCINumberIntPower ( OCIError             *err, 
                          CONST OCINumber      *base, 
                          CONST sword          exp,
                          OCINumber            *result );

Parameters

err (IN/OUT) -The OCI error handle. If there is an error, it is recorded in err and this function returns OCI_ERROR. Diagnostic information can be obtained by calling OCIErrorGet().

base (IN) - base of the exponentiation.

exp (IN) - exponent to which the base is to be raised.

result (OUT) - output of exponentiation.

Comments

Raises an arbitrary base to an arbitrary integer power.

This function returns an error if any of the number arguments is NULL.

Related Functions

OCIErrorGet()

OCINumberIsZero()

Purpose

Tests if the given number is equal to zero.

Syntax

sword OCINumberIsZero ( OCIError            *err,
                        CONST OCINumber     *number,
                        boolean             *result );

Parameters

err (IN/OUT) -The OCI error handle. If there is an error, it is recorded in err and this function returns OCI_ERROR. Diagnostic information can be obtained by calling OCIErrorGet().

number (IN) - number to be compared.

result (OUT) - set to TRUE if equal to zero; otherwise, set to FALSE.

Comments

Tests if the given number is equal to zero.

This function returns an error if any of the number arguments is NULL.

Related Functions

OCIErrorGet()

OCINumberLn()

Purpose

Takes the natural logarithm (base e) of an Oracle number.

Syntax

sword OCINumberLn ( OCIError              *err,
                    CONST OCINumber       *number,
                    OCINumber             *result );

Parameters

err (IN/OUT) - The OCI error handle. If there is an error, it is recorded in err and this function returns OCI_ERROR. Diagnostic information can be obtained by calling OCIErrorGet().

number (IN) - logarithm of this number is computed.

result (OUT) - logarithm result.

Comments

Takes the logarithm (base e) of the given Oracle number.

This function returns an error if any of the number arguments is NULL, or if numberI is less than or equal to zero.

Related Functions

OCIErrorGet()

OCINumberLog()

Purpose

Takes the logarithm, to any base, of an Oracle number.

Syntax

sword OCINumberLog ( OCIError              *err, 
                     CONST OCINumber       *base, 
                     CONST OCINumber       *number, 
                     OCINumber             *result );

Parameters

err (IN/OUT) - The OCI error handle. If there is an error, it is recorded in err and this function returns OCI_ERROR. Diagnostic information can be obtained by calling OCIErrorGet().

base (IN) - base of the logarithm.

number (IN) - operand.

result (OUT) - logarithm result.

Comments

Takes the logarithm with the specified base of an Oracle number.

This function returns an error if:

Related Functions

OCIErrorGet()

OCINumberMod()

Purpose

Gets the modulus (remainder) of the division of two Oracle numbers.

Syntax

sword OCINumberMod ( OCIError              *err,
                     CONST OCINumber       *number1, 
                     CONST OCINumber       *number2,
                     OCINumber             *result );

Parameters

err (IN/OUT) -The OCI error handle. If there is an error, it is recorded in err and this function returns OCI_ERROR. Diagnostic information can be obtained by calling OCIErrorGet().

number1 (IN) - pointer to the numerator.

number2 (IN) - pointer to the denominator.

result (OUT) - remainder of the result.

Comments

Finds the remainder of the division of two Oracle numbers.

This function returns an error if number1 or number2 is NULL, or if there is a divide-by-zero error.

Related Functions

OCIErrorGet()

OCINumberMul()

Purpose

Multiplies two Oracle numbers

Syntax

sword OCINumberMul ( OCIError              *err,
                     CONST OCINumber       *number1, 
                     CONST OCINumber       *number2,
                     OCINumber             *result );

Parameters

err (IN/OUT) -The OCI error handle. If there is an error, it is recorded in err and this function returns OCI_ERROR. Diagnostic information can be obtained by calling OCIErrorGet().

number1, number2 (IN) - numbers to be multiplied.

result (OUT) - multiplication result.

Comments

Multiplies number1 with number2 and returns result in result.

This function returns an error if any of the number arguments is NULL.

Related Functions

OCIErrorGet()

OCINumberNeg()

Purpose

Negates an Oracle number.

Syntax

sword OCINumberNeg ( OCIError              *err, 
                     CONST OCINumber       *number, 
                     OCINumber             *result );

Parameters

err (IN/OUT) - The OCI error handle. If there is an error, it is recorded in err and this function returns OCI_ERROR. Diagnostic information can be obtained by calling OCIErrorGet().

number (IN) - number to be negated.

result (OUT) - contains negated value of number.

Comments

Negates an Oracle number.

This function returns an error if any of the number arguments is NULL.

Related Functions

OCIErrorGet()

OCINumberPower()

Purpose

Raises a given base to a given exponent.

Syntax

sword OCINumberPower ( OCIError              *err,
                       CONST OCINumber       *base, 
                       CONST OCINumber       *number, 
                       OCINumber             *result );

Parameters

err (IN/OUT) - The OCI error handle. If there is an error, it is recorded in err and this function returns OCI_ERROR. Diagnostic information can be obtained by calling OCIErrorGet().

base (IN) - base of the exponentiation.

number (IN) - exponent to which the base is to be raised.

result (OUT) - output of exponentiation.

Comments

Raises an arbitrary base to an arbitrary power.

This function returns an error if any of the number arguments is NULL.

Related Functions

OCIErrorGet()

OCINumberRound()

Purpose

Rounds an Oracle number to a specified decimal place.

Syntax

sword OCINumberRound ( OCIError              *err,
                       CONST OCINumber       *number,
                       sword                 decplace,
                       OCINumber             *result );

Parameters

err (IN/OUT) -The OCI error handle. If there is an error, it is recorded in err and this function returns OCI_ERROR. Diagnostic information can be obtained by calling OCIErrorGet().

number (IN) - number to be rounded.

decplace (IN) - number of decimal digits to the right of the decimal point to round to. Negative values are allowed.

result (OUT) - output of rounding.

Comments

Rounds an Oracle number to a specified decimal place.

This function returns an error if any of the number arguments is NULL.

Related Functions

OCIErrorGet()

OCINumberSetZero()

Purpose

Initializes an Oracle number to zero

Syntax

void OCINumberSetZero ( OCIError      *err
                        OCINumber     *num ); 

Parameters

err (IN/OUT) -The OCI error handle. If there is an error, it is recorded in err and this function returns OCI_ERROR. Diagnostic information can be obtained by calling OCIErrorGet().

num (IN/OUT) - initialized to zero value.

Comments

Initializes the given number to value 0.

Related Functions

OCIErrorGet()

OCINumberSign()

Purpose

Gets sign of an Oracle number.

Syntax

sword OCINumberSign ( OCIError             *err, 
                      CONST OCINumber      *number, 
                      sword                *result );

Parameters

err (IN/OUT) - The OCI error handle. If there is an error, it is recorded in err and this function returns OCI_ERROR. Diagnostic information can be obtained by calling OCIErrorGet().

number (IN) - number whose sign is returned.

result (OUT) - possible values:

Value of number   Output in result parameter  

number < 0  

-1  

number == 0  

0  

number > 0  

1  

Comments

Obtains the sign of an Oracle number.

This function returns an error if number or result is NULL.

Related Functions

OCIErrorGet()

OCINumberSin()

Purpose

Takes the sine of an Oracle number.

Syntax

sword OCINumberSin ( OCIError              *err, 
                     CONST OCINumber       *number, 
                     OCINumber             *result );

Parameters

err (IN/OUT) - The OCI error handle. If there is an error, it is recorded in err and this function returns OCI_ERROR. Diagnostic information can be obtained by calling OCIErrorGet().

number (IN) - argument of the sine in radians.

result (OUT) - result of the sine.

Comments

Takes the sine in radians of an Oracle number.

This function returns an error if any of the number arguments is NULL.

Related Functions

OCIErrorGet()

OCINumberSqrt()

Purpose

Computes the square root of an Oracle number.

Syntax

sword OCINumberSqrt ( OCIError             *err,
                     CONST OCINumber      *number, 
                     OCINumber            *result );

Parameters

err (IN/OUT) - The OCI error handle. If there is an error, it is recorded in err and this function returns OCI_ERROR. Diagnostic information can be obtained by calling OCIErrorGet().

number (IN) - input number.

result (OUT) - output which will contain the square root of the input number.

Comments

Computes the square root of an Oracle number.

This function returns an error if number is NULL or number is negative.

Related Functions

OCIErrorGet()

OCINumberSub()

Purpose

Subtract two Oracle numbers.

Syntax

sword OCINumberSub ( OCIError             *err,
                     CONST OCINumber      *number1, 
                     CONST OCINumber      *number2, 
                     OCINumber            *result );

Parameters

err (IN/OUT) - The OCI error handle. If there is an error, it is recorded in err and this function returns OCI_ERROR. Diagnostic information can be obtained by calling OCIErrorGet().

number1, number2 (IN) - number2 is subtracted from number1.

result (OUT) - subtraction result.

Comments

Subtracts number2 from number1 and returns result in result.

This function returns an error if any of the number arguments is NULL.

Related Functions

OCIErrorGet()

OCINumberTan()

Purpose

Takes the tangent of an Oracle number.

Syntax

sword OCINumberTan ( OCIError              *err, 
                     CONST OCINumber       *number,
                     OCINumber             *result );

Parameters

err (IN/OUT) -The OCI error handle. If there is an error, it is recorded in err and this function returns OCI_ERROR. Diagnostic information can be obtained by calling OCIErrorGet().

number (IN) - argument of the tangent in radians.

result (OUT) - result of the tangent.

Comments

Takes the tangent in radians of an Oracle number.

This function returns an error if any of the number arguments is NULL.

Related Functions

OCIErrorGet()

OCINumberToInt()

Purpose

Converts an Oracle number type to integer.

Syntax

sword OCINumberToInt ( OCIError              *err,
                       CONST OCINumber       *number,
                       uword                 rsl_length,
                       uword                 rsl_flag, 
                       dvoid                 *rsl );

Parameters

err (IN/OUT) - The OCI error handle. If there is an error, it is recorded in err and this function returns OCI_ERROR. Diagnostic information can be obtained by calling OCIErrorGet().

number (IN) - number to be converted.

rsl_length (IN) - size of the desired result.

rsl_flag (IN) - flag denoting the desired sign of the output; set as follows:

Predefined Constant   Use  

OCI_NUMBER_UNSIGNED  

Unsigned values  

OCI_NUMBER_SIGNED  

Signed values  

rsl (OUT) - pointer to space for the result.

Comments

This is a native type conversion function. It converts the given Oracle number into an integer of the form xbn (e.g. ub2, ub4, sb2, etc.)

This function returns an error if number or rsl is NULL, if number is too big (overflow) or too small (underflow), or if an invalid sign flag value is passed in rsl_flag.

Related Functions

OCIErrorGet()

OCINumberToReal()

Purpose

Converts an Oracle number type to Real.

Syntax

sword OCINumberToReal ( OCIError            *err,
                        CONST OCINumber     *number,
                        uword               rsl_length,
                        dvoid               *rsl );

Parameters

err (IN/OUT) -The OCI error handle. If there is an error, it is recorded in err and this function returns OCI_ERROR. Diagnostic information can be obtained by calling OCIErrorGet().

number (IN) - number to be converted.

rsl_length (IN) - the size of the desired result. This will be equal to sizeof( float | double | long double).

rsl (OUT) - pointer to space for storing the result.

Comments

This is a native type conversion function. It converts an Oracle number into a machine-native real type. This function only converts numbers up to LDBL_DIG, DBL_DIG, or FLT_DIG digits of precision and removes trailing zeroes. The above constants are defined in float.h.

This function returns an error if number or rsl is NULL, or if rsl_length = 0.

Related Functions

OCIErrorGet(), OCINumberFromReal()

OCINumberToText()

Purpose

Converts an Oracle number to a character string.

Syntax

sword OCINumberToText ( OCIError             *err,
                        CONST OCINumber      *number, 
                        CONST text           *fmt, 
                        ub4                  fmt_length,
                        CONST text           *nls_params, 
                        ub4                  nls_p_length,
                        ub4                  *buf_size, 
                        text                 *buf );

Parameters

err (IN/OUT) - The OCI error handle. If there is an error, it is recorded in err and this function returns OCI_ERROR. Diagnostic information can be obtained by calling OCIErrorGet().

number (IN) - Oracle number to be converted.

fmt (IN) - conversion format.

fmt_length (IN) - length of the fmt parameter.

nls_params (IN) - NLS format specification. If NULL string (i.e., (text *)0 ), then the default parameters for the session is used.

nls_p_length (IN) - length of the nls_params parameter.

buf_size (IN) - size of the buffer.

buf (OUT) - buffer into which the converted string is placed.

Comments

Converts a given number to a character string according to a specified format. Refer to the TO_NUMBER conversion function described in the Oracle SQL Language Reference Manual for a description of format and NLS parameters.

The converted number string is stored in buf, up to a maximum of buf_size bytes. This function returns an error if:

Related Functions

OCIErrorGet()

OCINumberTrunc()

Purpose

Truncates an Oracle number at a specified decimal place.

Syntax

sword OCINumberTrunc ( OCIError             *err,
                       CONST OCINumber      *number, 
                       sword                decplace,
                       OCINumber            *result );

Parameters

err (IN/OUT) -The OCI error handle. If there is an error, it is recorded in err and this function returns OCI_ERROR. Diagnostic information can be obtained by calling OCIErrorGet().

number (IN) - input number.

decplace (IN) - number of decimal digits to the right of the decimal point at which to truncate. Negative values are allowed.

result (OUT) - output of truncation.

Comments

Truncates an Oracle number at a specified decimal place.

This function returns an error if any of the number arguments is NULL.

Related Functions

OCIErrorGet()

OCIRawAllocSize()

Purpose

Gets allocated size of raw memory in bytes.

Syntax

sword OCIRawAllocSize ( OCIEnv             *env,
                        OCIError           *err,
                        CONST OCIRaw       *raw,
                        ub4                *allocsize );

Parameters

env (IN/OUT) - The OCI environment handle initialized in object mode. See the description of OCIEnvInit() in Chapter 13 for more information.

err (IN/OUT) -The OCI error handle. If there is an error, it is recorded in err and this function returns OCI_ERROR. Diagnostic information can be obtained by calling OCIErrorGet().

raw (IN) - raw data whose allocated size in bytes is returned. This must be a non-NULL pointer.

allocsize (OUT) - the allocated size of raw memory in bytes is returned.

Comments

Retrieves the allocated size of the raw memory in bytes. The allocated size is greater than or equal to the actual raw size.

Related Functions

OCIErrorGet()

OCIRawAssignBytes()

Purpose

Assigns raw bytes of type ub1* to Oracle OCIRaw* datatype.

Syntax

sword OCIRawAssignBytes ( OCIEnv             *env,
                          OCIError           *err, 
                          CONST ub1          *rhs,
                          ub4                rhs_len,
                          OCIRaw             **lhs );

Parameters

env (IN/OUT) - The OCI environment handle initialized in object mode. See the description of OCIEnvInit() in Chapter 13 for more information.

err (IN/OUT) - The OCI error handle. If there is an error, it is recorded in err and this function returns OCI_ERROR. Diagnostic information can be obtained by calling OCIErrorGet().

rhs (IN) - right-hand side (source) of the assignment, of datatype ub1.

rhs_len (IN) - length of the rhs raw bytes.

lhs (IN/OUT) - left-hand side (target) of the assignment OCIRaw data.

Comments

Assigns rhs raw bytes to lhs raw datatype. The lhs raw may be resized depending upon the size of the rhs. The raw bytes assigned are of type ub1.

Related Functions

OCIErrorGet()

OCIRawAssignRaw()

Purpose

Assign one Oracle raw datatype to another Oracle raw datatype.

Syntax

sword OCIRawAssignRaw ( OCIEnv             *env,
                        OCIError           *err, 
                        CONST OCIRaw       *rhs, 
                        OCIRaw             **lhs );

Parameters

env (IN/OUT) - The OCI environment handle initialized in object mode. See the description of OCIEnvInit() in Chapter 13 for more information.

err (IN/OUT) - The OCI error handle. If there is an error, it is recorded in err and this function returns OCI_ERROR. Diagnostic information can be obtained by calling OCIErrorGet().

rhs (IN) - right-hand side (source) of the assignment; OCIRaw data.

lhs (IN/OUT) - left-hand side (target) of the assignment; OCIRaw data.

Comments

Assigns rhs raw to lhs raw. The lhs raw may be resized depending upon the size of the rhs.

Related Functions

OCIErrorGet()

OCIRawPtr()

Purpose

Gets pointer to raw data.

Syntax

ub1 *OCIRawPtr ( OCIEnv             *env,
                 CONST OCIRaw       *raw );

Parameters

env (IN/OUT) - The OCI environment handle initialized in object mode. See the description of OCIEnvInit() in Chapter 13 for more information.

raw (IN) - pointer to the data of a given raw is returned.

Returns

pointer to the data of a given raw.

Comments

Returns a pointer to the data of a given raw.

Related Functions

OCIErrorGet()

OCIRawResize()

Purpose

Resizes the memory of a given variable-length raw.

Syntax

sword OCIRawResize ( OCIEnv          *env, 
                     OCIError        *err,
                     ub2             new_size, 
                     OCIRaw          **raw );

Parameters

env (IN/OUT) - The OCI environment handle initialized in object mode. See the description of OCIEnvInit() in Chapter 13 for more information.

err (IN/OUT) - The OCI error handle. If there is an error, it is recorded in err and this function returns OCI_ERROR. Diagnostic information can be obtained by calling OCIErrorGet().

new_size (IN) - new size of the raw data in bytes.

raw (IN) - variable-length raw pointer; the raw is resized to new_size.

Comments

This function resizes the memory of the given variable-length raw in the object cache. The previous contents of the raw are not preserved. This function may allocate the raw in a new memory region in which case the original memory occupied by the given raw will be freed. If the input raw is NULL (raw == NULL), then this function will allocate memory for the raw data.

If the new_size is 0, then this function frees the memory occupied by raw and a NULL pointer value is returned.

Related Functions

OCIErrorGet()

OCIRawSize()

Purpose

Gets the size of a given raw.

Syntax

ub4 OCIRawSize ( OCIEnv             *env,
                 CONST OCIRaw       *raw );

Parameters

env (IN/OUT) - The OCI environment handle initialized in object mode. See the description of OCIEnvInit() in Chapter 13 for more information.

raw (IN/OUT) - raw whose size is returned.

Returns

size of the raw in bytes.

Comments

Returns the size of the given raw in bytes.

Related Functions

OCIErrorGet()

OCIRefAssign()

Purpose

Assigns one REF to another, such that both reference the same object.

Syntax

sword OCIRefAssign ( OCIEnv             *env, 
                     OCIError           *err, 
                     CONST OCIRef       *source, 
                     OCIRef             **target );

Parameters

env (IN/OUT) - The OCI environment handle initialized in object mode. See the description of OCIEnvInit() in Chapter 13 for more information.

err (IN/OUT) - The OCI error handle. If there is an error, it is recorded in err and this function returns OCI_ERROR. Diagnostic information can be obtained by calling OCIErrorGet().

source (IN) - REF to copy from.

target (IN/OUT) - REF to copy to.

Comments

Copies source REF to target REF; both then reference the same object. If the target REF pointer is NULL (i.e. *target == NULL), then OCIRefAssign() will allocate memory for the target REF in the OCI object cache prior to the copy.

Related Functions

OCIErrorGet()

OCIRefClear()

Purpose

Clears or nullifies a REF

Syntax

void OCIRefClear ( OCIEnv        *env,
                   OCIRef        *ref );

Parameters

env (IN/OUT) - The OCI environment handle initialized in object mode. See the description of OCIEnvInit() in Chapter 13 for more information.

ref (IN/OUT) - REF to clear.

Comments

Clears or nullifies the given REF. A REF is considered to be a NULL REF if it no longer points to an object. Logically, a NULL REF is a dangling REF.

Note that a null ref is still a valid SQL value and is not SQL-ly null. It can be used as a valid non-null constant ref value for NOT NULL column or attribute of a row in a table.

If a NULL pointer value is passed as a REF, then this function is a no-op.

Related Functions

OCIErrorGet()

OCIRefFromHex()

Purpose

Converts the given hexadecimal string into a REF.

Syntax

sword OCIRefFromHex ( OCIEnv              *env, 
                      OCIError            *err, 
                      CONST OCISvcCtx     *svc, 
                      CONST text          *hex, 
                      ub4                 length, 
                      OCIRef              **ref );

Parameters

env (IN/OUT) - The OCI environment handle initialized in object mode. See the description of OCIEnvInit() in Chapter 13 for more information.

err (IN/OUT) - The OCI error handle. If there is an error, it is recorded in err and this function returns OCI_ERROR. Diagnostic information can be obtained by calling OCIErrorGet().

svc (IN) - OCI service context handle; if the resulting ref is initialized with this service context.

hex (IN) - hexadecimal text string (that was produced by OCIRefToHex() previously) to be convert into a REF.

length (IN) - length of the hexadecimal text string.

ref (IN/OUT) - the REF into which the hexadecimal string is converted. If *ref is NULL on input, then space for the REF is allocated in the object cache, otherwise the memory occupied by the given REF is re-used.

Comments

Converts the given hexadecimal text string into a REF. This function ensures that the resulting REF is well formed. It does not ensure that the object pointed to by the resulting REF exists or not.

Related Functions

OCIErrorGet()

OCIRefHexSize()

Purpose

Tests if a REF is NULL

Syntax

ub4 OCIRefHexSize ( OCIEnv            *env,
                    CONST OCIRef      *ref );

Parameters

env (IN/OUT) - The OCI environment handle initialized in object mode. See the description of OCIEnvInit() in Chapter 13 for more information.

ref (IN) - REF whose size in hexadecimal representation in bytes is returned.

Returns

The size of the hexadecimal representation of the REF.

Comments

Returns the size of the buffer in bytes required for the hexadecimal representation of the ref. A buffer of at least this size must be passed to the ref-to-hex (OCIRefToHex()) conversion function.

Related Functions

OCIRefAssign()

OCIRefIsEqual()

Purpose

Compares two REFs to determine if they are equal.

Syntax

boolean OCIRefIsEqual ( OCIEnv              *env,
                        CONST OCIRef        *x,
                        CONST OCIRef        *y );

Parameters

env (IN/OUT) - The OCI environment handle initialized in object mode. See the description of OCIEnvInit() in Chapter 13 for more information.

x (IN) - REF to compare.

y (IN) - REF to compare.

Returns

TRUE if the two REFs are equal

FALSE if the two REFs are not equal, or x is NULL, or y is NULL

Comments

Compares the given REFs for equality.

Two REFs are equal if and only if they are both referencing the same object, whether persistent or transient.

Note: Two NULL REFs are considered not equal by this function.

Related Functions

OCIErrorGet()

OCIRefIsNull()

Purpose

Tests if a REF is NULL

Syntax

boolean OCIRefIsNull ( OCIEnv           *env,
                       CONST OCIRef     *ref );

Parameters

env (IN/OUT) - The OCI environment handle initialized in object mode. See the description of OCIEnvInit() in Chapter 13 for more information.

ref (IN) - REF to test for NULL.

Returns

TRUE if the given REF is NULL.

FALSE if the given REF is not NULL.

Comments

Returns TRUE if the given REF is NULL; otherwise, returns FALSE.

A REF is NULL if and only if:

Note: A REF is a dangling REF if the object that it points to does not exist.

Related Functions

OCIErrorGet()

OCIRefToHex()

Purpose

Converts a REF to a hexadecimal string

Syntax

sword OCIRefToHex ( OCIEnv            *env,
                    OCIError          *err, 
                    CONST OCIRef      *ref, 
                    text              *hex, 
                    ub4               *hex_length );

Parameters

env (IN/OUT) - The OCI environment handle initialized in object mode. See the description of OCIEnvInit() in Chapter 13 for more information.

err (IN/OUT) - The OCI error handle. If there is an error, it is recorded in err and this function returns OCI_ERROR. Diagnostic information can be obtained by calling OCIErrorGet().

ref (IN) - REF to be converted into a hexadecimal string; if ref is a NULL REF (i.e. OCIRefIsNull(ref) == TRUE) then zero hex_length value is returned.

hex (OUT) - buffer that is large enough to contain the resulting hexadecimal string; the contents of the string is opaque to the caller.

hex_length (IN/OUT) - on input specifies the size of the hex buffer on output specifies the actual size of the hexadecimal string being returned in hex.

Comments

Converts the given REF into a hexadecimal string, and returns the length of the string. The resulting string is opaque to the caller.

This function returns an error if the given buffer is not big enough to hold the resulting string.

Related Functions

OCIErrorGet(), OCIRefHexSize(), OCIRefIsNull()

OCIStringAllocSize()

Purpose

Gets allocated size of string memory in bytes.

Syntax

sword OCIStringAllocSize ( OCIEnv              *env,
                           CONST OCIString     *vs,
                           ub4                 *allocsize ); 

Parameters

env (IN/OUT) - The OCI environment handle initialized in object mode. See the description of OCIEnvInit() in Chapter 13 for more information.

vs (IN) - string whose allocated size in bytes is returned. vs must be a non-NULL pointer.

allocsize (OUT) - the allocated size of string memory in bytes is returned.

Comments

Returns the allocated size of the string memory in bytes. The allocated size is greater than or equal to the actual string size.

Related Functions

OCIErrorGet()

OCIStringAssign()

Purpose

Assigns one string to another string.

Syntax

sword OCIStringAssign ( OCIEnv               *env, 
                        OCIError             *err, 
                        CONST OCIString      *rhs, 
                        OCIString            **lhs );

Parameters

env (IN/OUT) - The OCI environment handle initialized in object mode. See the description of OCIEnvInit() in Chapter 13 for more information.

err (IN/OUT) - The OCI error handle. If there is an error, it is recorded in err and this function returns OCI_ERROR. Diagnostic information can be obtained by calling OCIErrorGet().

rhs (IN) - right-hand side (source) of the assignment.

lhs (IN/OUT) - left-hand side (target) of the assignment.

Comments

Assigns rhs string to lhs string. The lhs string may be resized depending upon the size of the rhs. The assigned string is NULL-terminated.

The length field will not include the extra byte needed for null termination.

This function returns an error if the assignment operation runs out of space.

Related Functions

OCIErrorGet()

OCIStringAssignText()

Purpose

Assigns the source text string to the target string.

Syntax

sword OCIStringAssignText ( OCIEnv           *env,
                            OCIError         *err, 
                            CONST text       *rhs, 
                            ub2              rhs_len,
                            OCIString        **lhs );

Parameters

env (IN/OUT) - The OCI environment handle initialized in object mode. See the description of OCIEnvInit() in Chapter 13 for more information.

err (IN/OUT) - The OCI error handle. If there is an error, it is recorded in err and this function returns OCI_ERROR. Diagnostic information can be obtained by calling OCIErrorGet().

rhs (IN) - right-hand side (source) of the assignment, a text string.

rhs_len (IN) - length of the rhs string.

lhs (IN/OUT) - left-hand side (target) of the assignment.

Comments

Assigns rhs string to lhs string. The lhs string may be resized depending upon the size of the rhs. The assigned string is NULL-terminated.

The length field will not include the extra byte needed for null termination.

Related Functions

OCIErrorGet()

OCIStringPtr()

Purpose

Gets a pointer to a given string.

Syntax

text *OCIStringPtr ( OCIEnv               *env,
                     CONST OCIString      *vs );

Parameters

env (IN/OUT) - The OCI environment handle initialized in object mode. See the description of OCIEnvInit() in Chapter 13 for more information.

vs (IN) - pointer to the text of this string is returned.

Returns

pointer to the text of the string.

Comments

Returns the pointer to the text of the given string.

Related Functions

OCIErrorGet()

OCIStringResize()

Purpose

Resizes the memory of a given string.

Syntax

sword OCIStringResize ( OCIEnv          *env,
                        OCIError        *err,
                        ub4             new_size,
                        OCIString       **str );

Parameters

env (IN/OUT) - The OCI environment handle initialized in object mode. See the description of OCIEnvInit() in Chapter 13 for more information.

err (IN/OUT) - The OCI error handle. If there is an error, it is recorded in err and this function returns OCI_ERROR. Diagnostic information can be obtained by calling OCIErrorGet().

new_size (IN) - new memory size of the string in bytes.

str (IN/OUT) - allocated memory for the string which is freed from the OCI object cache.

Comments

This function resizes the memory of the given variable-length string in the object cache. The contents of the string are not preserved. This function may allocate the string in a new memory region, in which case the original memory occupied by the given string will be freed. If the input string is NULL (str == NULL), then this function will allocate memory for the string.

If the new_size is 0, then this function frees the memory occupied by str and a NULL pointer value is returned.

Note: new_size must include space for the NULL character ('\0') as string terminator.

Related Functions

OCIErrorGet()

OCIStringSize()

Purpose

Gets string size.

Syntax

ub4 OCIStringSize ( OCIEnv              *env,
                    CONST OCIString     *vs );

Parameters

env (IN/OUT) - The OCI environment handle initialized in object mode. See the description of OCIEnvInit() in Chapter 13 for more information.

vs (IN) - string whose size is returned.

Returns

size of the string in bytes.

Comments

Returns the size of the given string in bytes. The returned size does not include an extra byte for NULL termination.

Related Functions

OCIErrorGet()

OCITableDelete()

Purpose

Deletes the element at the specified index.

Syntax

sword OCITableDelete ( OCIEnv          *env, 
                       OCIError        *err, 
                       sb4             index, 
                       OCITable        *tbl );

Parameters

env (IN/OUT) - The OCI environment handle initialized in object mode. See the description of OCIEnvInit() in Chapter 13 for more information.

err (IN/OUT) - The OCI error handle. If there is an error, it is recorded in err and this function returns OCI_ERROR. Diagnostic information can be obtained by calling OCIErrorGet().

index (IN) - index of the element which must be deleted.

tbl (IN) - table whose element is deleted.

Comments

Deletes the element at the given index.

Note: The position ordinals of the remaining elements of the table are not changed by OCITableDelete(). The delete operation creates "holes" in the table.

This function returns an error if:

Related Functions

OCIErrorGet()

OCITableExists()

Purpose

Tests whether an element exists at the given index.

Syntax

sword OCITableExists ( OCIEnv              *env,
                       OCIError            *err, 
                       CONST OCITable      *tbl,
                       sb4                 index, 
                       boolean             *exists );

Parameters

env (IN/OUT) - The OCI environment handle initialized in object mode. See the description of OCIEnvInit() in Chapter 13 for more information.

err (IN/OUT) - The OCI error handle. If there is an error, it is recorded in err and this function returns OCI_ERROR. Diagnostic information can be obtained by calling OCIErrorGet().

tbl (IN) - table in which the given index is checked.

index (IN) - index of the element which is checked for existence.

exists (OUT) - set to TRUE if element at given index exists; otherwise, it is set to FALSE.

Comments

Tests whether an element exists at the given index, index.

This function returns an error if any input parameter is NULL.

Related Functions

OCIErrorGet()

OCITableFirst()

Purpose

Returns the first index of an existing element in a given table.

Syntax

sword OCITableFirst ( OCIEnv             *env, 
                      OCIError           *err,
                      CONST OCITable     *tbl, 
                      sb4                *index  );

Parameters

env (IN/OUT) - The OCI environment handle initialized in object mode. See the description of OCIEnvInit() in Chapter 13 for more information.

err (IN/OUT) - The OCI error handle. If there is an error, it is recorded in err and this function returns OCI_ERROR. Diagnostic information can be obtained by calling OCIErrorGet().

tbl (IN) - table which is scanned.

index (OUT) - first index of the element which exists in the given table is returned.

Comments

Returns the index of the first element which exists in a given table.

For example, if OCITableDelete() deleted the first 5 elements of a table, OCITableFirst() returns 6.

See OCITableDelete() for information regarding non-data "holes" in tables.

This function returns an error if the table is empty.

Related Functions

OCIErrorGet(), OCITableDelete()

OCITableLast()

Purpose

Returns the index of the last existing element of a table.

Syntax

sword OCITableLast ( OCIEnv              *env, 
                     OCIError            *err, 
                     CONST OCITable      *tbl, 
                     sb4                 *index );

Parameters

env (IN/OUT) - The OCI environment handle initialized in object mode. See the description of OCIEnvInit() in Chapter 13 for more information.

err (IN/OUT) - The OCI error handle. If there is an error, it is recorded in err and this function returns OCI_ERROR. Diagnostic information can be obtained by calling OCIErrorGet().

tbl (IN) - table which is scanned.

index (OUT) - index of the last existing element in the table.

Comments

Returns the index of the last existing element in the given table.

This function returns an error if the table is empty.

Related Functions

OCIErrorGet()

OCITableNext()

Purpose

Returns the index of the next existing element of a table.

Syntax

sword OCITableNext ( OCIEnv             *env, 
                     OCIError           *err, 
                     sb4                index, 
                     CONST OCITable     *tbl, 
                     sb4                *next_index
                     boolean            *exists );

Parameters

env (IN/OUT) - The OCI environment handle initialized in object mode. See the description of OCIEnvInit() in Chapter 13 for more information.

err (IN/OUT) - The OCI error handle. If there is an error, it is recorded in err and this function returns OCI_ERROR. Diagnostic information can be obtained by calling OCIErrorGet().

index (IN) - index for starting point of scan.

tbl (IN) - table which is scanned.

next_index (OUT) -index of the next existing element after tbl(index).

exists (OUT) - FALSE if no next index is available, else TRUE.

Comments

Returns the smallest position j, greater than index, such that exists(j) is TRUE

See Also: Refer to the description of OCIStringAllocSize() on page 15-90, regarding the existence of non-data "holes" in tables.

Related Functions

OCITablePrev()

OCITablePrev()

Purpose

Returns the index of the previous existing element of a table.

Syntax

sword OCITablePrev ( OCIEnv             *env, 
                     OCIError           *err, 
                     sb4                index,
                     CONST OCITable     *tbl,
                     sb4                *prev_index
                     boolean            *exists );

Parameters

env (IN/OUT) - The OCI environment handle initialized in object mode. See the description of OCIEnvInit() in Chapter 13 for more information.

err (IN/OUT) - The OCI error handle. If there is an error, it is recorded in err and this function returns OCI_ERROR. Diagnostic information can be obtained by calling OCIErrorGet().

index (IN) - index for starting point of scan.

tbl (IN) - table which is scanned.

prev_index (OUT) - index of the previous existing element before tbl(index).

exists (OUT) - FALSE if no previous index is available, else TRUE.

Comments

Return the largest position j, less than index, such that exists(j) is TRUE

See Also: Refer to the description of OCIStringAllocSize() on page 15-90, regarding the existence of non-data "holes" in tables.

Related Functions

OCITableNext()

OCITableSize()

Purpose

Return size of the given table (not including deleted elements).

Syntax

sword OCITableSize ( OCIEnv             *env,
                     OCIError           *err,
                     CONST OCITable     *tbl
                     sb4                *size );

Parameters

env (IN/OUT) - The OCI environment handle initialized in object mode. See the description of OCIEnvInit() in Chapter 13 for more information.

err (IN/OUT) - The OCI error handle. If there is an error, it is recorded in err and this function returns OCI_ERROR. Diagnostic information can be obtained by calling OCIErrorGet().

tbl (IN) - nested table whose number of elements is returned.

size (OUT) - current number of elements in the nested table. The count does not include deleted elements.

Comments

Returns the count of elements in the given table.

This count will be decremented upon deleting elements from the nested table. So this count does not include any "holes" created by deleting elements. To get the count not including the deleted elements, use OCICollSize().

For example:

OCITableSize(...); 
// assume 'size' returned is equal to 5
OCITableDelete(...); // delete one element
OCITableSize(...);
// 'size' returned is equal to 4

To get the count plus the count of deleted elements use OCICollSize(). Continuing the above example:

OCICollSize(...)
// 'size' returned is still equal to 5

This function returns an error if an error occurs during the loading of the nested table into the object cache, or if any of the input parameters is NULL.

Related Functions

OCICollSize()




Prev

Next
Oracle
Copyright © 1997 Oracle Corporation.

All Rights Reserved.

Library

Product

Contents

Index