Re: Converting integers to chars
Posted in 1997
Steve Hook wrote:
>
> Anybody knows how to convert integers to char on a select statement?
>
> I need to do the following:
>
> select format(a) from t
>
> a is an integer and I need to format it as a 10 character string (padding
> with spaces if a is less
> than 10 characters long)
>
> Does such a format function exist?
Using what frontend? In SPL, ESQL/C or 4GL just:
DEFINE holder char(10)
SELECT a INTO holder FROM t;
-OR-
exec sql begin declare section;
char holder[11];
exec sql end declare section;
exec sql select a into :holder from t;
All this assumes that the select returns one row, otherwise use
appropriate loops and cursors.
In dbaccess this is not possible except to the extent that dbaccess
converts all data to fixed length character for display.
Art S. Kagel