Newsgroups: comp.databases Path: utzoo!utgpu!watserv1!watmath!att!att!cbnewsl!cbnewsk!barton From: barton@cbnewsk.att.com (jim.m.barton) Subject: Re: Informix question, character columns Organization: AT&T Bell Laboratories Date: Wed, 28 Nov 90 23:05:31 GMT Message-ID: <1990Nov28.230531.11939@cbnewsk.att.com> Summary: use "string" psuedo-datatype References: <1990Nov28.110715.22247@lth.se> Lines: 42 In article <1990Nov28.110715.22247@lth.se>, newsuser@efd.lth.se (News server connection) writes: > > Is it possible to have null-terminated character strings > in a character column? The ESQL/C manual mention that it is possible. > But my strings gets filled with spaces up to the length of the column. > > Is there a way to do this? Yes. INFORMIX ESQL/C supports a psuedo datatype, "string", to be used for host variables for this sitution. Host variables declared as "string" are generated as a normal "char" variables in the C code but signal to the DBMS to suppress trailing blanks AND terminate with an end-of-string when making assignments to those host variables. Example, Suppose we have a table: create table name_table ( name char(100) ); insert into name_table(name) values("SMITH "); The following code should retrieve name_table.name using a "string" host variable: $ string name_value[101]; /* Note added byte for end-of-string */ $ select name into :name_value from name_table; printf("name is '%s'\n", name_value); The result should be: name is 'SMITH'