Translating with DrWatson… this can take a few seconds the first time.
This is a genuine, complex translation. DrWatson protects commands, error codes, and log output while naturally translating the surrounding text. It’s translated once and saved.
Chuan Lu asked whether changing columns from CHAR to VARCHAR changes ESQL/C behaviour. Madison Pruet said ESQL/C sees no difference; use char[x+1] and data converts automatically. Jonathan Leffler noted CHAR host variables may get blank padding, defeating VARCHAR's benefit, but no recompile is needed. Fernando Nunes warned to be careful with indexed columns.
Auto-generated by Claude from the posts below — may be imperfect; read the full thread.
HI,
A customer use ESQL/C to write the application, they want to change some data
type from char to varchar, the customer want to know whether the running
result will be changed ?
What's the internal difference between char and varchar data type with ESQL/C?
thanks for your time.
↪ replying to CHUAN LU
Madison Pruet — — source: IIUG Forums & Mailing Lists
From the esql/c side there is no difference between a char and a varchar. You
write the esql/c program with the data being defined as a char[x+1] where 'x'
is the max size that the varchar is defined to be. Of course the "+1" is to
provide space for the null terminator.
When the data is moved from the database to/from the esql/c program, it will
automatically converted into the target definition.
Madison Pruet
Retired and Loving it
On Thursday, July 13, 2017 8:47 AM, CHUAN LU <luchuan@cn.ibm.com> wrote:
HI,
A customer use ESQL/C to write the application, they want to change some data
type from char to varchar, the customer want to know whether the running
result will be changed ?
What's the internal difference between char and varchar data type with ESQL/C?
thanks for your time.
*******************************************************************************
Forum Note: Use "Reply" to post a response in the discussion forum.
On Thu, Jul 13, 2017 at 7:46 AM, CHUAN LU <luchuan@cn.ibm.com> wrote:
> A customer use
> âsâ
> ESQL/C to write the application
> â. They want to change some data
> type
> âsâ
> from char to varchar,
> âand â
> the customer want
> âsâ
> to know whether the running
> result will be changed?
>
âIt depends in part on how the ESQL/C is written. However, if it uses the
CHAR data type (rather than say the string data type), then it is possible
that you'll get blank padding on the stringsâ, which moots one of the main
benefits of using VARCHAR. OTOH, it will continue to work without
recompilation.
> What's the internal difference between char and varchar data type with
> ESQL/C?
>
âPrimarily that SQL and ESQL/C don't blank pad VARCHAR data. On disk,
there's a byte stored for the length of the VARCHAR; that doesn't translate
to the in-memory representation which is essentially the same as CHAR.
â
--
Jonathan Leffler <jonathan.leffler@gmail.com> #include <disclaimer.h>
Guardian of DBD::Informix - v2015.1101 - http://dbi.perl.org
"Blessed are we who can laugh at ourselves, for we shall never cease to be
amused."
What is the reason to change a char for a varchar?
If the column(s) are indexed be careful with the change... I assume the
only valid reason for the change would be to save some space... but that
comes with a cost, specially if the data is indexed.
Regards
On Thu, Jul 13, 2017 at 3:46 PM, CHUAN LU <luchuan@cn.ibm.com> wrote:
> HI,
>
> A customer use ESQL/C to write the application, they want to change some
> data
> type from char to varchar, the customer want to know whether the running
> result will be changed ?
>
> What's the internal difference between char and varchar data type with
> ESQL/C?
>
> thanks for your time.
>
>
> ************************************************************
> *******************
> Forum Note: Use "Reply" to post a response in the discussion forum.
>
>
--
Fernando Nunes
Portugal
http://informix-technology.blogspot.com
My email works... but I don't check it frequently...
We use strictly necessary cookies to make this site work. With your
consent we’d also use optional cookies for analytics and marketing. You can accept all,
reject all, or choose. Read our Cookie Policy.