SAND CDBMS Tools Reference Guide
NDL++ Functions:
Syntax and Examples


Return to String Function Index

 

String Function Syntax and Examples


GENKEYCOL( )

The GENKEYCOL() function returns a 19-character string that is unique for each unique input set, unless one of the referenced columns is NULL, in which case a null value is returned. Note that the same combination of input values will return the same output string, so the GENKEYCOL() function will not produce a true primary key unless the input columns are known to be collectively unique.

GENKEYCOL() is similar to GENKEY(), but takes columns specified in the map specification as input rather than fields defined in the RECORD section. This means that the internal database representation of the input data will be used to generate keys instead of the ASCII representation of the data in flat files, allowing GENKEYCOL() output strings to be compared accurately with those produced by the SQL function GENKEY().

Warning:
The key produced with the same input set can differ between operating systems, which might affect the cross-platform portability of data and/or scripts.


Syntax:

GENKEYCOL( arg1 [ {, argN} ... ] )

where:

The argument(s) can be any column previously defined in the map specification section. Up to ten arguments (arg1, arg2, ..., arg10) can be included. The returned key will be unique for each unique, NOT NULL combination of columns specified. If any one input column is NULL, a null value will be returned instead.

Note that an error will be generated if GENKEYCOL() references a column that is described after the place where this function appears in the mapping section.


Example:

input: col1, col2, col3

 IMPORT @sample.dat
{

RECORD
{
field1 *,
field2 *,
field3 *\r\n
}
schema1.table1
{
col1 field1
col2 field2
col3 field3
col4 GENKEYCOL(col1, col2, col3)
}

}


Results:

schema1.table1.col1 first-name
schema1.table1.col2 last-name
schema1.table1.col3  employee-number
schema1.table1.col4  unique string


Note that if the example map specification had looked like this:

col1 field1
col2 field2
col3 GENKEYCOL(col1, col2, col4)
col4 field3

an error would result, since GENKEYCOL() requires that its input columns be mapped before the function is defined.

 

Return to String Function Index