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


Return to String Function Index

 

String Function Syntax and Examples


CMP( )

The CMP() function performs a standard ASCII value comparison on two strings, reading from left to right; it returns 0 when the strings are equal, a number greater than 0 when string1 has a greater ASCII value at the first position where the two strings differ, and a number less than 0 when string1 has a lesser ASCII value at the first position where the two strings differ.

Syntax:

CMP(string1,string2[,[CASEINSENS | 0] | [CASESENS | 1] ])  

where:

The optional CASEINSENS | CASESENS argument determines whether the comparison is to be case-sensitive (cases must match) or case-insensitive. The CASEINSENS and CASESENS arguments can be replaced by 0 and 1, respectively. By default, NDL++ searches are case-sensitive.

Example:

input: sampleString,samplestring

IMPORT @sample.dat
{

VAR
{
V1 CMP(field1,field2)
V2 CMP(field1,field2,0)
}
RECORD
{
field1 *,
field2 *\r\n
}
schema1.table1
{
col1 %V1>0 ?'greater':(%V1<0?'less':'equal')
col2 %V2>0 ?'greater':(%V2<0?'less':'equal')
}

}


Results:

schema1.table1.col1 'less'
schema1.table1.col2 'equal

 

Return to String Function Index