In article <47040019@hpcc01.corp.hp.com>, dallara@hpcc01.corp.hp.com (Jon
Dallara) says:
>
>
>**** esql/c program to illustrate bug ****
>
>/* bad-prog.ec -- esql test program */
>
>#include <stdio.h>
>
>$char csKey3[2];
>
Try declaring this to be 3 characters long (or longer - remember the NULL
byte for the end of the string in C?) Then your code might work properly.
You must add one byte to the size of the database field when
reading/writing chars! ESQL/C will only return what it can fit
into the field, otherwise you will corrupt memory, one of the
sqlca.sqlwarn variables is set if a truncation of field length has
happened.
>main()
>{
> $DATABASE oedlamp;
>
> $DECLARE c CURSOR
> FOR SELECT key3
> INTO $csKey3
> FROM results_keys
> WHERE key1 = "1BEVA-3300";
>
> $OPEN c;
>
> $FETCH c;
>
> printf("key3 = |%.*s|\\n", sizeof(csKey3), csKey3);
>
> $CLOSE c;
> $CLOSE database;
>}
>
>
>**** bad-prog output: notice that only a "P" was returned, instead of
"PA" ****