Progress
Embedded SQL-92
Guide and Reference


Explicit Data Comparison Using SQL and syscalctable

Alternatively, you can compare two data values using an SQL-92 statement, as follows:

EXEC SQL BEGIN DECLARE SECTION ;
    DATE date1_v ;
    DATE date2_v ;
    SHORT result_v ;
EXEC SQL END DECLARE SECTION ;
   .
   .
   .
EXEC SQL
     SELECT :date1_v - :date2_v
     INTO :result_v
     FROM sysprogress.syscalctable ;
if (sqlca.sqlcode == 0)
{
     if (result_v > 0)
          printf ("date1_v > date2_v ") ;
     else
          if (result_v < 0)
               printf ("date1_v < date2_v ") ;
          else
               printf ("date1_v = date2_v ") ;
}
/*
** Error handling logic here, for unsuccessful SELECT operation.
*/ 

The result is the difference in the number of days between the two given dates, date1_v and date2_v.

NOTE: When your application must be portable to another RDBMS, use SQL-92 statements for data comparisons. When performance is the priority, use the SQL-92 API call tpe_compare_data to improve the performance of your application program.


Copyright © 2004 Progress Software Corporation
www.progress.com
Voice: (781) 280-4000
Fax: (781) 280-4095