Re: ESQL/C, COBOL and CHAR
Posted in 1998
Volker Fraenkle wrote: > > Hello, > we have a little problem to send COBOL-Structures with compressed digits > to IDS via ESQL/C. > > Here is an Example: > > COBOL: > > 01 MY-RECORD. > 05 FIELD1 PIC XX. > 05 FIELD2 PIC 999999 COMP-3. > > Values of FIELD1: "AB" > Values of FIELD2: 121171 > > HEX Value of MY-RECORD: 41 42 00 12 11 71 > > If we try to send MY-RECORD to a field like CHAR(10) via ESQL/C, > MY-RECORD will truncated after FIELD1. > > If we send MY-RECORD to ORACLE CHAR(10), the whole record will be saved. Informix indicates a character field containing a NULL as its value by storing a zero byte in the first character, much as you are doing with the specific COBOL COMP-3 value you describe. Ignoring the problems with trying to pack binary data into a character field, we are guilty also and I am still dealing with the repercussions of my predecessors decision to do that, you will need to add an additional character to the field that is to contain the COMP-3 and prepend a non-zero byte to the COMP-3 string in the ESQL/C module that will store it. Obviously you will have to strip the additional character in ESQL/C also (you cannot use a substring in the SQL as the resulting string will be interpreted as a NULL anyway). It might be better to just convert the comp-3 to Informix DECIMAL type for storage then you can also search on it and update and query it using standard tools not just from COBOL. Art S. Kagel