Previous Topic

Next Topic

Using c-treeSQL for Condition Evaluation

A c-treeSQL SELECT statement can be used for condition evaluation in an ESQL program. The condition evaluation is done using the SYSCALCTABLE.

The following example shows the usage of the SELECT statement to check whether the ship_date is valid:

Example Using c-treeSQL for Condition Evaluation


EXEC SQL
     SELECT 1
     INTO   :result
     FROM   admin.syscalctable
     WHERE  :ship_date > SYSDATE
             AND :ship_date < ADD_MONTHS (:order_date, 1) ;

if (sqlca.sqlcode == 0)
    printf ("ship_date valid ") ;
else
if (sqlca.sqlcode == SQL_NOT_FOUND)
    printf ("ship_date invalid ") ;
else
    printf ("Error ") ;

The previous example returns the value 1 if the validation is successful. If not, the validation is unsuccessful.