Need help with ESQL/C - Possible BUG?
Posted in 1994
Hello Problem Solvers, I have encountered a problem with esql/c and haven't been able to solve it. :-( PROBLEM: Data looks fine in isql (key3). When 'fetched' from esql/c it returns only 1 byte from a 2 byte field. **** isql run **** RUN: Next Restart Exit Display the next page of query results. --------------------- oedlamp ---------------- Press CTRL-W for Help -------- pointer 1 key1 1BEVA-3300 key2 EVA-3300 key3 PA key4 03/20/1983 key5 05/07/1992 key6 03-015 key7 key8 925 key9 0 key10 0 key11 0 key12 0 key13 0 key14 0 key15 **** isql table info **** RUN - "summit".results_keys: Next Restart Exit Display the next page of query results. --------------------- oedlamp ---------------- Press CTRL-W for Help -------- Column name Type Nulls pointer serial no key1 char(16) no key2 char(16) no key3 char(2) yes key4 date yes key5 date yes key6 char(20) yes key7 char(6) yes key8 smallint yes key9 smallint yes key10 integer yes key11 integer yes key12 smallint yes key13 smallint yes **** esql/c program to illustrate bug **** /* bad-prog.ec -- esql test program */ #include <stdio.h> $char csKey3[2]; 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" **** key3 = |P| **** esql/c program to illustrate that the above code does work **** /* good-prog.ec -- esql test program */ #include <stdio.h> $char csKey2[16]; main() { $DATABASE oedlamp; $DECLARE c CURSOR FOR SELECT key2 INTO $csKey2 FROM results_keys WHERE key1 = "1BEVA-3300"; $OPEN c; $FETCH c; printf("key2 = |%.*s|\\n", sizeof(csKey2), csKey2); $CLOSE c; $CLOSE database; } **** good-prog output is fine **** key2 = |EVA-3300 | I don't remember expressing any views; if I did, they are from me, not the company I currently work for. Bill Sperry Hewlett Packard, Optoelectronics (408) 435-6841 bills@hpoemg.sj.hp.com OED, San Jose, CA