Oracle® Call Interface Programmer's Guide, 10g Release 2 (10.2) Part Number B14250-02 |
|
|
View PDF |
This section describes the OCI NUMBER
functions.
See Also:
"OCINumber Examples"Table 18-12 NUMBER Functions
Function/Page | Purpose |
---|---|
Computes the absolute value |
|
Adds |
|
Computes the arc cosine |
|
Computes the arc sine |
|
Computes the arc tangent |
|
Computes the arc tangent of two |
|
Assigns one |
|
Computes the ceiling of |
|
Compares |
|
Computes the cosine |
|
Decrements a |
|
Divides two |
|
Raises e to the specified Oracle |
|
Computes the floor of a |
|
Converts an integer to an Oracle |
|
Convert a real to an Oracle |
|
Convert a string to an Oracle |
|
Computes the hyperbolic cosine |
|
Computes the hyperbolic sine |
|
Computes the hyperbolic tangent |
|
Increments an Oracle |
|
Raises a given base to an integer power |
|
Tests if a |
|
Tests if a |
|
Computes the natural logarithm |
|
Computes the logarithm to an arbitrary base |
|
Modulo division |
|
Multiplies |
|
Negates a |
|
Exponentiation to base e |
|
Rounds a |
|
Rounds an Oracle |
|
Initializes a |
|
Initializes a |
|
Multiplies by 10, shifting specified number of decimal places |
|
Obtains the sign of an Oracle |
|
Computes the sine |
|
Computes the square root of a |
|
Subtracts |
|
Computes the tangent |
|
Converts an Oracle |
|
Converts an Oracle |
|
Converts an array of |
|
Converts an Oracle |
|
Truncates an Oracle |
Purpose
Computes the absolute value of an Oracle number.
Syntax
sword OCINumberAbs ( OCIError *err, CONST OCINumber *number, OCINumber *result );
Parameters
The OCI error handle. If there is an error, it is recorded in err
and this function returns OCI_ERROR
. Obtain diagnostic information by calling OCIErrorGet()
.
Input number.
The absolute value of the input number.
Comments
This function returns an error if any of the number arguments is NULL
.
Related Functions
Purpose
Adds two Oracle numbers together.
Syntax
sword OCINumberAdd ( OCIError *err, CONST OCINumber *number1, CONST OCINumber *number2, OCINumber *result );
Parameters
The OCI error handle. If there is an error, it is recorded in err
and this function returns OCI_ERROR
. Obtain diagnostic information by calling OCIErrorGet()
.
Numbers to be added.
Result of adding number1
to number2
.
Comments
This function returns an error if any of the number arguments is NULL
.
Related Functions
Purpose
Takes the arc cosine in radians of an Oracle number.
Syntax
sword OCINumberArcCos ( OCIError *err, CONST OCINumber *number, OCINumber *result );
Parameters
The OCI error handle. If there is an error, it is recorded in err
and this function returns OCI_ERROR
. Obtain diagnostic information by calling OCIErrorGet()
.
Argument of the arc cosine.
Result of the arc cosine in radians.
Comments
This function returns an error if any of the number arguments is NULL
, or if number
is less than -1 or if number
is greater than 1.
Related Functions
Purpose
Takes the arc sine in radians of an Oracle number.
Syntax
sword OCINumberArcSin ( OCIError *err, CONST OCINumber *number, OCINumber *result );
Parameters
The OCI error handle. If there is an error, it is recorded in err
and this function returns OCI_ERROR
. Obtain diagnostic information by calling OCIErrorGet()
.
Argument of the arc sine.
Result of the arc sine in radians.
Comments
This function returns an error if any of the number arguments is NULL
, or if number
is less than -1 or if number
is greater than 1.
Related Functions
Purpose
Takes the arc tangent in radians of an Oracle number.
Syntax
sword OCINumberArcTan ( OCIError *err, CONST OCINumber *number, OCINumber *result );
Parameters
The OCI error handle. If there is an error, it is recorded in err
and this function returns OCI_ERROR
. Obtain diagnostic information by calling OCIErrorGet()
.
Argument of the arc tangent.
Result of the arc tangent in radians.
Comments
This function returns an error if any of the number arguments is NULL
.
Related Functions
Purpose
Takes the arc tangent of two Oracle numbers.
Syntax
sword OCINumberArcTan2 ( OCIError *err, CONST OCINumber *number1, CONST OCINumber *number2, OCINumber *result );
Parameters
The OCI error handle. If there is an error, it is recorded in err
and this function returns OCI_ERROR
. Obtain diagnostic information by calling OCIErrorGet()
.
Argument 1 of the arc tangent.
Argument 2 of the arc tangent.
Result of the arc tangent in radians.
Comments
This function returns an error if any of the number arguments is NULL
, or if number2
is equal to 0.
Related Functions
Purpose
Assigns one Oracle number to another Oracle number.
Syntax
sword OCINumberAssign ( OCIError *err, CONST OCINumber *from, OCINumber *to );
Parameters
The OCI error handle. If there is an error, it is recorded in err
and this function returns OCI_ERROR
. Obtain diagnostic information by calling OCIErrorGet()
.
NUMBER
to be assigned.
NUMBER
copied into.
Comments
Assigns the number identified by from
to the number identified by to
.
This function returns an error if any of the number arguments is NULL
.
Related Functions
Purpose
Computes the ceiling value of an Oracle number.
Syntax
sword OCINumberCeil ( OCIError *err, CONST OCINumber *number, OCINumber *result );
Parameters
The OCI error handle. If there is an error, it is recorded in err
and this function returns OCI_ERROR
. Obtain diagnostic information by calling OCIErrorGet()
.
Input number.
Output which will contain the ceiling value of the input number.
Comments
This function returns an error if any of the number arguments is NULL
.
Related Functions
OCIErrorGet(), OCINumberFloor()
Purpose
Compares two Oracle numbers.
Syntax
sword OCINumberCmp ( OCIError *err, CONST OCINumber *number1, CONST OCINumber *number2, sword *result );
Parameters
The OCI error handle. If there is an error, it is recorded in err
and this function returns OCI_ERROR
. Obtain diagnostic information by calling OCIErrorGet()
.
NUMBER
s to compare.
Comparison result:
Table 18-13 Comparison Results
Comparison result | Output in result parameter |
---|---|
number1 < number2 |
negative |
number1 = number2 |
0 |
number1 > number2 |
positive |
Comments
This function returns an error if any of the number arguments is NULL
.
Related Functions
OCIErrorGet(), OCINumberAssign()
Purpose
Computes the cosine in radians of an Oracle number.
Syntax
sword OCINumberCos ( OCIError *err, CONST OCINumber *number, OCINumber *result );
Parameters
The OCI error handle. If there is an error, it is recorded in err
and this function returns OCI_ERROR
. Obtain diagnostic information by calling OCIErrorGet()
.
Argument of the cosine in radians.
Result of the cosine.
Comments
This function returns an error if any of the number arguments is NULL
.
Related Functions
OCIErrorGet(), OCINumberArcCos()
Purpose
Decrements an OCINumber.
Syntax
sword OCINumberDec ( OCIError *err, OCINumber *number );
Parameters
The OCI error handle. If there is an error, it is recorded in err
and this function returns OCI_ERROR
. Obtain diagnostic information by calling OCIErrorGet()
.
A positive Oracle NUMBER
to be decremented.
Comments
Decrements an Oracle number in place. It is assumed that the input is an integer between 0 and 100^21-2. If the is input too large, it will be treated as 0 - the result will be an Oracle number 1. If the input is not a positive integer, the result will be unpredictable.
This function returns an error if the input number is NULL
.
Related Functions
Purpose
Divides two Oracle NUMBER
s.
Syntax
sword OCINumberDiv ( OCIError *err, CONST OCINumber *number1, CONST OCINumber *number2, OCINumber *result );
Parameters
The OCI error handle. If there is an error, it is recorded in err
and this function returns OCI_ERROR
. Obtain diagnostic information by calling OCIErrorGet()
.
Pointer to the numerator.
Pointer to the denominator.
Division result.
Comments
Divides number1
by number2
and returns result in result
.
This function returns an error if:
any of the number arguments is NULL
there is an underflow error
there is a divide-by-zero error
Related Functions
Purpose
Raises e to the specified Oracle number power.
Syntax
sword OCINumberExp ( OCIError *err, CONST OCINumber *number, OCINumber *result );
Parameters
The OCI error handle. If there is an error, it is recorded in err
and this function returns OCI_ERROR
. Obtain diagnostic information by calling OCIErrorGet()
.
This function raises e to this Oracle number power.
Output of exponentiation.
Comments
This function returns an error if any of the number arguments is NULL
.
Related Functions
Purpose
Computes the floor value of an Oracle NUMBER
.
Syntax
sword OCINumberFloor ( OCIError *err, CONST OCINumber *number, OCINumber *result );
Parameters
The OCI error handle. If there is an error, it is recorded in err
and this function returns OCI_ERROR
. Obtain diagnostic information by calling OCIErrorGet()
.
Input NUMBER
.
The floor value of the input NUMBER
.
Comments
This function returns an error if any of the number arguments is NULL
.
Related Functions
OCIErrorGet(), OCINumberCeil()
Purpose
Converts an integer to an Oracle number.
Syntax
sword OCINumberFromInt ( OCIError *err, CONST dvoid *inum, uword inum_length, uword inum_s_flag, OCINumber *number );
Parameters
The OCI error handle. If there is an error, it is recorded in err
and this function returns OCI_ERROR
. Obtain diagnostic information by calling OCIErrorGet()
.
Pointer to the integer to convert.
Size of the integer.
Flag that designates the sign of the integer, as follows:
OCI_NUMBER_UNSIGNED
- Unsigned values
OCI_NUMBER
_SIGNED - Signed values
Given integer converted to Oracle number.
Comments
This is a native type conversion function. It converts any Oracle standard machine-native integer type, such as ub4
or 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(), OCINumberToInt()
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
The OCI error handle. If there is an error, it is recorded in err
and this function returns OCI_ERROR
. Obtain diagnostic information by calling OCIErrorGet()
.
Pointer to the floating point number to convert.
The size of the desired result, which equals sizeof
({float
| double
| long double
}).
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(), OCINumberToReal()
Purpose
Converts character string to Oracle NUMBER
.
Syntax
sword OCINumberFromText ( OCIError *err, CONST OraText *str, ub4 str_length, CONST OraText *fmt, ub4 fmt_length, CONST OraText *nls_params, ub4 nls_p_length, OCINumber *number );
Parameters
The OCI error handle. If there is an error, it is recorded in err
and this function returns OCI_ERROR
. Obtain diagnostic information by calling OCIErrorGet()
.
Input string to convert to Oracle NUMBER
.
Size of the input string.
Conversion format.
Length of the fmt
parameter.
Global Support format specification. If it is the NULL
string (""), then the default parameters for the session is used.
Length of the nls_params
parameter.
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 Database SQL Reference for a description of format and multilingual parameters.
This function returns an error if there is an invalid format, an invalid multibyte format, or an invalid input string, if number
or str
is NULL
, or if str_length
is zero.
Related Functions
OCIErrorGet(), OCINumberToText()
Purpose
Computes the hyperbolic cosine of an Oracle NUMBER
.
Syntax
sword OCINumberHypCos ( OCIError *err, CONST OCINumber *number, OCINumber *result );
Parameters
The OCI error handle. If there is an error, it is recorded in err
and this function returns OCI_ERROR
. Obtain diagnostic information by calling OCIErrorGet()
.
Argument of the cosine hyperbolic.
Result of the cosine hyperbolic.
Comments
This function returns an error if either of the NUMBER arguments is NULL
.
Caution:
An OracleNUMBER
overflow causes an unpredictable result value.Related Functions
OCIErrorGet(), OCINumberHypSin(), OCINumberHypTan()
Purpose
Computes the hyperbolic sine of an Oracle NUMBER
.
Syntax
sword OCINumberHypSin ( OCIError *err, CONST OCINumber *number, OCINumber *result );
Parameters
The OCI error handle. If there is an error, it is recorded in err
and this function returns OCI_ERROR
. Obtain diagnostic information by calling OCIErrorGet()
.
Argument of the sine hyperbolic.
Result of the sine hyperbolic.
Comments
This function returns an error if either of the NUMBER
arguments is NULL
.
Caution:
An Oracle number overflow causes an unpredictable result value.Related Functions
OCIErrorGet(), OCINumberHypSin(), OCINumberHypTan()
Purpose
Computes the hyperbolic tangent of an Oracle NUMBER
.
Syntax
sword OCINumberHypTan ( OCIError *err, CONST OCINumber *number, OCINumber *result );
Parameters
The OCI error handle. If there is an error, it is recorded in err
and this function returns OCI_ERROR
. Obtain diagnostic information by calling OCIErrorGet()
.
Argument of the tangent hyperbolic.
Result of the tangent hyperbolic.
Comments
This function returns an error if either of the NUMBER
arguments is NULL
.
Caution:
An OracleNUMBER
overflow causes an unpredictable result value.Related Functions
OCIErrorGet(), OCINumberHypCos(), OCINumberHypSin()
Purpose
Increments an OCINumber.
Syntax
sword OCINumberInc ( OCIError *err, OCINumber *number );
Parameters
The OCI error handle. If there is an error, it is recorded in err
and this function returns OCI_ERROR
. Obtain diagnostic information by calling OCIErrorGet()
.
A positive Oracle NUMBER
to be incremented.
Comments
Increments an Oracle NUMBER
in place. It is assumed that the input is an integer between 0 and 100^21-2. If the is input too large, it will be treated as 0 - the result will be an Oracle NUMBER
1. If the input is not a positive integer, the result will be unpredictable.
This function returns an error if the input NUMBER
is NULL
.
Related Functions
Purpose
Raises a given base to a given integer power.
Syntax
sword OCINumberIntPower ( OCIError *err, CONST OCINumber *base, CONST sword exp, OCINumber *result );
Parameters
The OCI error handle. If there is an error, it is recorded in err
and this function returns OCI_ERROR
. Obtain diagnostic information by calling OCIErrorGet()
.
Base of the exponentiation.
Exponent to which the base is raised.
Output of exponentiation.
Comments
This function returns an error if either of the NUMBER
arguments is NULL
.
Related Functions
OCIErrorGet(), OCINumberPower()
Purpose
Tests if an OCINumber is an integer.
Syntax
sword OCINumberIsInt ( OCIError *err, CONST OCINumber *number, boolean *result );
Parameters
The OCI error handle. If there is an error, it is recorded in err
and this function returns OCI_ERROR
. Obtain diagnostic information by calling OCIErrorGet()
.
NUMBER
to be tested
Set to TRUE
if integer value else FALSE
Comments
This function returns an error if number
or result
is NULL
.
Related Functions
OCIErrorGet(), OCINumberRound(), OCINumberTrunc()
Purpose
Tests if the given NUMBER
is equal to zero.
Syntax
sword OCINumberIsZero ( OCIError *err, CONST OCINumber *number, boolean *result );
Parameters
The OCI error handle. If there is an error, it is recorded in err
and this function returns OCI_ERROR
. Obtain diagnostic information by calling OCIErrorGet()
.
NUMBER
to compare.
Set to TRUE
if equal to zero; otherwise, set to FALSE
.
Comments
This function returns an error if the NUMBER
argument is NULL
.
Related Functions
OCIErrorGet(), OCINumberSetZero()
Purpose
Takes the natural logarithm (base e) of an Oracle NUMBER
.
Syntax
sword OCINumberLn ( OCIError *err, CONST OCINumber *number, OCINumber *result );
Parameters
The OCI error handle. If there is an error, it is recorded in err
and this function returns OCI_ERROR
. Obtain diagnostic information by calling OCIErrorGet()
.
Logarithm of this NUMBER
is computed.
Logarithm result.
Comments
This function returns an error if either of the NUMBER
arguments is NULL
, or if number
is less than or equal to zero.
Related Functions
OCIErrorGet(), OCINumberExp(), 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
The OCI error handle. If there is an error, it is recorded in err
and this function returns OCI_ERROR
. Obtain diagnostic information by calling OCIErrorGet()
.
Base of the logarithm.
Operand.
Logarithm result.
Comments
This function returns an error if:
any of the NUMBER
arguments is NULL
number
<= 0
base
<= 0
Related Functions
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
The OCI error handle. If there is an error, it is recorded in err
and this function returns OCI_ERROR
. Obtain diagnostic information by calling OCIErrorGet()
.
Pointer to the numerator.
Pointer to the denominator.
Remainder of the result.
Comments
This function returns an error if number1
or number2
is NULL
, or if there is a divide-by-zero error.
Related Functions
Purpose
Multiplies two Oracle NUMBERs
.
Syntax
sword OCINumberMul ( OCIError *err, CONST OCINumber *number1, CONST OCINumber *number2, OCINumber *result );
Parameters
The OCI error handle. If there is an error, it is recorded in err
and this function returns OCI_ERROR
. Obtain diagnostic information by calling OCIErrorGet()
.
NUMBER
to multiply.
NUMBER
to multiply.
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
Purpose
Negates an Oracle NUMBER
.
Syntax
sword OCINumberNeg ( OCIError *err, CONST OCINumber *number, OCINumber *result );
Parameters
The OCI error handle. If there is an error, it is recorded in err
and this function returns OCI_ERROR
. Obtain diagnostic information by calling OCIErrorGet()
.
NUMBER
to negate.
Contains negated value of number
.
Comments
This function returns an error if either of the NUMBER
arguments is NULL
.
Related Functions
OCIErrorGet(), OCINumberAbs(), OCINumberSign()
Purpose
Raises a given base to a given exponent.
Syntax
sword OCINumberPower ( OCIError *err, CONST OCINumber *base, CONST OCINumber *number, OCINumber *result );
Parameters
The OCI error handle. If there is an error, it is recorded in err
and this function returns OCI_ERROR
. Obtain diagnostic information by calling OCIErrorGet()
.
Base of the exponentiation.
Exponent to which the base is to be raised.
Output of exponentiation.
Comments
This function returns an error if any of the NUMBER
arguments is NULL
.
Related Functions
Purpose
Rounds an OCINumber
to a specified number of decimal digits.
Syntax
sword OCINumberPrec ( OCIError *err, CONST OCINumber *number, eword nDigs, OCINumber *result );
Parameters
The OCI error handle. If there is an error, it is recorded in err
and this function returns OCI_ERROR
. Obtain diagnostic information by calling OCIErrorGet()
.
The number for which to set precision.
The number of decimal digits desired in the result.
The result.
Comments
Performs a floating point round with respect to the number of digits.
This function returns an error 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
The OCI error handle. If there is an error, it is recorded in err
and this function returns OCI_ERROR
. Obtain diagnostic information by calling OCIErrorGet()
.
NUMBER
to round.
Number of decimal digits to the right of the decimal point to round to. Negative values are allowed.
Output of rounding.
Comments
This function returns an error if any of the NUMBER
arguments is NULL
.
Related Functions
OCIErrorGet(), OCINumberTrunc()
Purpose
Sets an OCINumber
to Pi.
Syntax
void OCINumberSetPi ( OCIError *err, OCINumber *num );
Parameters
The OCI error handle. If there is an error, it is recorded in err
and this function returns OCI_ERROR
. Obtain diagnostic information by calling OCIErrorGet()
.
NUMBER
set to the value of Pi.
Comments
Initializes the given NUMBER
to the value of Pi.
Related Functions
Purpose
Initializes an Oracle NUMBER
to zero.
Syntax
void OCINumberSetZero ( OCIError *err OCINumber *num );
Parameters
A valid OCI error handle. This function does not check for errors because the function will never produce an error.
NUMBER to initialize to zero value.
Comments
None.
Related Functions
Purpose
Multiplies a NUMBER
by a power of 10 by shifting it a specified number of decimal places.
Syntax
sword OCINumberShift ( OCIError *err, CONST OCINumber *number, CONST sword nDig, OCINumber *result );
Parameters
The OCI error handle. If there is an error, it is recorded in err
and this function returns OCI_ERROR
. Obtain diagnostic information by calling OCIErrorGet()
.
Oracle NUMBER
to be shifted.
Number of decimal places to shift.
Shift result.
Comments
Multiplies number
by 10^nDig
and sets product
to the result.
This function returns an error if the input number
is NULL
.
Related Functions
Purpose
Gets sign of an Oracle NUMBER
.
Syntax
sword OCINumberSign ( OCIError *err, CONST OCINumber *number, sword *result );
Parameters
The OCI error handle. If there is an error, it is recorded in err
and this function returns OCI_ERROR
. Obtain diagnostic information by calling OCIErrorGet()
.
NUMBER
whose sign is returned.
Possible values:
Table 18-14 Values of result
Value of number | Output in result parameter |
---|---|
number < 0 |
-1 |
number == 0 |
0 |
number > 0 |
1 |
Comments
This function returns an error if number
or result
is NULL
.
Related Functions
Purpose
Computes the sine in radians of an Oracle NUMBER
.
Syntax
sword OCINumberSin ( OCIError *err, CONST OCINumber *number, OCINumber *result );
Parameters
The OCI error handle. If there is an error, it is recorded in err
and this function returns OCI_ERROR
. Obtain diagnostic information by calling OCIErrorGet()
.
Argument of the sine in radians.
Result of the sine.
Comments
This function returns an error if either of the NUMBER
arguments is NULL
.
Related Functions
OCIErrorGet(), OCINumberArcSin()
Purpose
Computes the square root of an Oracle NUMBER
.
Syntax
sword OCINumberSqrt ( OCIError *err, CONST OCINumber *number, OCINumber *result );
Parameters
The OCI error handle. If there is an error, it is recorded in err
and this function returns OCI_ERROR
. Obtain diagnostic information by calling OCIErrorGet()
.
Input NUMBER
.
Output which will contain the square root of the input NUMBER
.
Comments
This function returns an error if number
is NULL
or number
is negative.
Related Functions
OCIErrorGet(), OCINumberPower()
Purpose
Subtract two Oracle NUMBER
s.
Syntax
sword OCINumberSub ( OCIError *err, CONST OCINumber *number1, CONST OCINumber *number2, OCINumber *result );
Parameters
The OCI error handle. If there is an error, it is recorded in err
and this function returns OCI_ERROR
. Obtain diagnostic information by calling OCIErrorGet()
.
This function subtracts number2
from number1
.
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
Purpose
Computes the tangent in radians of an Oracle NUMBER
.
Syntax
sword OCINumberTan ( OCIError *err, CONST OCINumber *number, OCINumber *result );
Parameters
The OCI error handle. If there is an error, it is recorded in err
and this function returns OCI_ERROR
. Obtain diagnostic information by calling OCIErrorGet()
.
Argument of the tangent in radians.
Result of the tangent.
Comments
This function returns an error if any of the NUMBER
arguments is NULL
.
Related Functions
OCIErrorGet(), OCINumberArcTan(), OCINumberArcTan2()
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
The OCI error handle. If there is an error, it is recorded in err
and this function returns OCI_ERROR
. Obtain diagnostic information by calling OCIErrorGet()
.
NUMBER
to convert.
Size of the desired result.
Flag that designates the sign of the output, as follows:
OCI_NUMBER_UNSIGNED
- Unsigned values
OCI_NUMBER_SIGNED
- Signed values
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
, such as ub2
, ub4
, or sb2
.
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(), OCINumberFromInt()
Purpose
Converts an Oracle NUMBER
type to real.
Syntax
sword OCINumberToReal ( OCIError *err, CONST OCINumber *number, uword rsl_length, dvoid *rsl );
Parameters
The OCI error handle. If there is an error, it is recorded in err
and this function returns OCI_ERROR
. Obtain diagnostic information by calling OCIErrorGet()
.
NUMBER
to convert.
The size of the desired result, which equals sizeof
({ float
| double
| long double
}).
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 NUMBER
s up to LDBL_DIG, DBL_DIG, or FLT_DIG digits of precision and removes trailing zeroes. These constants are defined in float.h
.
You must pass a valid OCINumber
to this function. Otherwise, the result is undefined.
Related Functions
OCIErrorGet(), OCINumberFromReal()
Purpose
Converts an array of NUMBER
to an array of real.
Syntax
sword OCINumberToRealArray ( OCIError *err, CONST OCINumber **number, uword elems, uword rsl_length, dvoid *rsl );
Parameters
The OCI error handle. If there is an error, it is recorded in err
and this function returns OCI_ERROR
. Obtain diagnostic information by calling OCIErrorGet()
.
Pointer to array of NUMBER
to be converted.
Maximum number of NUMBER
pointers.
The size of the desired result, that is, sizeof({ float | double | long double
})
.
Pointer to array of space for storing the result.
Comments
Native type conversion function that 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 constants are defined in the float.h
header file.
You must pass a valid OCINumber
to this function. Otherwise, the result is undefined.
Returns
OCI_SUCCESS
- the function completes successfully.
OCI_INVALID_HANDLE
- if err
is NULL
.
OCI_ERROR
- if number
or rsl
is NULL
, or rsl_length
is 0.
Related Functions
OCIErrorGet(), OCINumberToReal()
Purpose
Converts an Oracle NUMBER
to a character string according to a specified format.
Syntax
sword OCINumberToText ( OCIError *err, CONST OCINumber *number, CONST OraText *fmt, ub4 fmt_length, CONST OraText *nls_params, ub4 nls_p_length, ub4 *buf_size, text *buf );
Parameters
The OCI error handle. If there is an error, it is recorded in err
and this function returns OCI_ERROR
. Obtain diagnostic information by calling OCIErrorGet()
.
Oracle NUMBER
to convert.
Conversion format.
Length of the fmt
parameter.
Global Support format specification. If it is a NULL
string ((text *)0
), then the default parameters for the session is used.
Length of the nls_params
parameter.
Size of the buffer.
Buffer into which the converted string is placed.
Comments
Refer to the TO_NUMBER conversion function described in the Oracle Database SQL Reference for a description of format and Global Support parameters.
The converted number string is stored in buf
, up to a maximum of buf_size
bytes. This function returns an error if:
number
or buf
is NULL
buffer is too small
invalid format or invalid multibyte format is passed
number to text translation for given format causes an overflow
Related Functions
OCIErrorGet(), OCINumberFromText()
Purpose
Truncates an Oracle NUMBER
at a specified decimal place.
Syntax
sword OCINumberTrunc ( OCIError *err, CONST OCINumber *number, sword decplace, OCINumber *result );
Parameters
The OCI error handle. If there is an error, it is recorded in err
and this function returns OCI_ERROR
. Obtain diagnostic information by calling OCIErrorGet()
.
Input NUMBER
.
Number of decimal digits to the right of the decimal point at which to truncate. Negative values are allowed.
Output of truncation.
Comments
This function returns an error if any of the NUMBER
arguments is NULL
.
Related Functions