Problem:
You may see that data defined in a VARCHAR host -variable appears as "padded" with spaces when examining the record on the database.
Is it possible to stop data from being padded when written out this way?
Resolution:
To avoid this from happening you can declare your host variables with the new Open ESQL syntax that is now supported in Net Express - CHAR-VARYING, which is a synonym for VARCHAR. The Net Express documentation describe this new syntax as follows:
CHAR-VARYING Example:
01 hv-name SQL TYPE IS CHAR-VARYING(n)
generates
01 hv-name pic x(n).
CHAR-VARYING data is passed to OpenESQL as SQL_VARCHAR. When data is sent to the data source, trailing spaces are trimmed, except for the first space if the value is all spaces, and values fetched from the data source are padded with spaces.
Having the ANSI padding checked on the driver should trim off any NULLS.
