skip to main content
OpenAccess SDK SQL Engine core methods for .NET : Helper classes : scalar_function class : Using scalar_function to specify result details and map to a column
 

Using scalar_function to specify result details and map to a column

Use this method to define a scalar function with specific values for precision, scale, and length of the result of the scalar function and to control whether the scalar function should be mapped to a column. The length, precision, and scale of the result of the scalar functions can be explicitly defined or set to DAM_NOT_SET to use the defaults. Default values are indicated in the description of the arguments in the following table. For details on setting the length, precision, and scale, refer to the corresponding fields in the OA_COLUMNS table in Chapter 5 "Schema definition and management" of the OpenAccess SDK SQL Engine Programmer’s Guide.
scalar_function (
String sName,
int iMapAsColumn,
int iConstantFunc,
String pfScalarFunc,
int iResXoType,
int iLength,
int iPrecision,
int iScale,
int iNumInputParams)
If you want to define a scalar function that has a qualifier, use the following syntax:
scalar_function (
String sQualifierName,
String sName,
int iMapAsColumn,
int iConstantFunc,
String pfScalarFunc,
int iResXoType,
int iLength,
int iPrecision,
int iScale,
int iNumInputParams)
 
Table 42: Parameters for scalar_function when specifying result details and mapping to a column 
Parameter
Type
Description
IN
 
 
sQualifierName
String
The name of the function qualifier
sName
String
The name of the scalar function
iMapAsColumn
int
Map function as column. Set it to 0 for normal scalar functions.
1 – map the function as a column.
0 – map the function as a normal scalar function.
iConstantFunc
int
Indicates whether the function has constant output.
1 – indicates that the function is a constant scalar function and is evaluated only once per query if all its arguments are literal values.
0 – indicates that the function is a variable scalar function and therefore should be evaluated once per record during the dam_isTargetRow call, regardless of the input.
pfScalarFunc
String
The method in the IP that is to be called to execute this scalar function.
iResXoType
int
The data type of the result value of the scalar function.
iLength
int
Length of the result value of the scalar function. Set to DAM_NOT_SET to accept the following default values:
CHAR, BINARY: 255
WVARCHAR: 16000
VARCHAR, VARBINARY: 8000
LONGVARCHAR, LONGVARBINARY: 1000000
WLONGVARCHAR: 2000000
NUMERIC: 34
Other types: Default values as specified in OA_COLUMNS
iPrecision
int
Precision of the result value of the scalar function. Set to DAM_NOT_Set to accept the following default values:
CHAR, WCHAR, BINARY: 255
VARCHAR, WVARCHAR, VARBINARY: 8000
LONGVARCHAR, WLONGVARCHAR,
LONGVARBINARY: 1000000
NUMERIC: 32
Other types: Default values as specified in OA_COLUMNS
iScale
int
Scale of the result value of the scalar function.
Set to DAM_NOT_SET to accept the following default value:
NUMERIC: 5
Other types: Default values as specified in OA_COLUMNS
iNumInputParams
int
The number of arguments expected by the function.
>=0 to allow a fixed argument list
< 0 to allow variable argument list with a maximum of |args|
RETURN
 
 
 
NONE
 

See also 

dam_isTargetRow