Progress
Embedded SQL-92
Guide and Reference


Explicit Data Conversion Using Scalar Functions

Alternatively, you can convert one data type to another data type using scalar functions. See Chapter 4, “SQL-92 Functions,” in the Progress SQL-92 Guide and Reference for additional information on scalar functions.

EXAMPLE

The following examples show two of the conversions available using scalar functions:

EXEC SQL BEGIN DECLARE SECTION ;
     numeric num_val_v ;
     date date_val_v ;
EXEC SQL END DECLARE SECTION ;
 
EXEC SQL
     SELECT TO_DATE (’10/10/1999’)
     INTO :date_val_v
     FROM sysprogress.syscalctable ;
 
EXEC SQL
     SELECT TO_NUMBER (’1234’)
     INTO :num_val_v
     FROM sysprogress.syscalctable ; 

The first example converts the character expression ’10/10/1999’ to a DATE data type, using the TO_DATE scalar function. The result is returned in date_val_v. The second example converts character expression ’1234’ to NUMERIC type using the TO_NUMBER scalar function. The result is returned in num_val_v.

Some of the other scalar functions available for conversion are TO_CHAR and TO_TIME. See Chapter 4, “SQL-92 Functions,” in the Progress SQL-92 Guide and Reference for additional information on scalar functions.


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