Name

lt , lte , gt , gte , equ , neq — comparison functions

Synopsis

lt ( in arg1 any ,
  in arg2 any );
 
lte ( in arg1 any ,
  in arg2 any );
 
gt ( in arg1 any ,
  in arg2 any );
 
gte ( in arg1 any ,
  in arg2 any );
 
equ ( arg1 any ,
  arg2 any );
 
neq ( in arg1 any ,
  in arg2 any );
 

Description

These functions return 1 if their first argument is less than (lt), less than or equivalent (lte), greater than (gt), greater than or equivalent (gte), equivalent (equ), or not equivalent (neq) to the second argument, respectively. If the arguments are not of the same type, then an appropriate type coercion is done for them before comparison.

These functions correspond to SQL query operators <, <=, >, >=, = and <> and are needed because the SQL syntax does not allow these operators to be used on the left side of FROM keyword in a SELECT statement.

Parameters

arg1 , arg2

integer , float , double precision , varchar or NULL .

Return Values

An integer value of 1 or 0 is returned.

Examples

Example 24.101. Simple Example

lt('pata','pato')  -> 1 (Yes, 'pata' is less than 'pato')
gt('barbar','bar')  -> 1 (Yes, 'barbar' is greater than 'bar')
equ(17,17)    -> 1 (seventeen is seventeen)
equ(17,17.0)    -> 1 (regardless of number format)
equ(atof('17.0'),17.0))  -> 1 (as it seems be)
equ(atof('17.1'),17.1))  -> 0 (But not always! Beware!)
gte(1234,NULL)    -> 0 (No, 1234 is not "greater"
        than or equal to NULL)
lt(1234,NULL)    -> 1 (Instead, it is "less" than NULL)