PROBLEMS WITH PREPARE/DESCRIBE in ESQLC
Posted in 1998
Topics: Connectivity: ESQL/C, 4GL & Embedded SQL
PROBLEMS WITH PREPARE/DESCRIBE in ESQLC I am experiencing problems with ESQLC code written in a Motorola Unix System V with Standard Engine environment and recently moved to a SCO Unix and ONLINE environment. Original Motorola Unix R32V3 INFORMIX-SQL Version 4.10.UC3 Thu Apr 16 14:05:26 PDT 1992 (SE) INFORMIX-ESQL Version 4.10.UC1 New SCO UNIX Openserver Version 5.0.0.b INFORMIX-OnLine Version 7.20.UC2 (Workgroup Server) INFORMIX-ESQL Version 7.20.UC2 One of the standard Informix demo programs namely demo3.ec works (after removing new features) on the Motorola / SE environment but not in the SCO/Online environment. Example program output and code is shown below :- #### PROGRAM OUTPUT ############ There are 6 returned columns: Column 1: type = 2, len = 4, name = ovrref Column 2: type = 2, len = 4, name = ovrchqno Column 3: type = 8, len = 4098, name = ovrexrate Column 4: type = 0, len = 8, name = ovracno_p Column 5: type = 0, len = 8, name = ovracno_t Column 6: type = 2, len = 4, name = ovrordno Got Here Memory fault(coredump) The problem appears to be in the fetch statement although when using similar code in a customised perform I receive the following -410 Prepare statement failed or was not executed. ############# PROGRAM SOURCE ################ #include <stdio.h> EXEC SQL include sqlda; EXEC SQL include sqltypes; main() { struct sqlda *demo3_ptr; struct sqlvar_struct *col_ptr; static char data_buff[1024]; int pos, cnt, size; EXEC SQL BEGIN DECLARE SECTION; short int i, desc_count; char demoquery[80]; EXEC SQL END DECLARE SECTION; EXEC SQL connect to 'sa_phones'; sprintf(demoquery, "%s ", "select * from overall;"); EXEC SQL prepare demo3id from :demoquery; EXEC SQL declare demo3cursor cursor for demo3id; EXEC SQL describe demo3id into demo3_ptr; desc_count = demo3_ptr->sqld; printf("There are %d returned columns:\\n", desc_count); /* Print out what DESCRIBE returns */ for (i = 1; i <= desc_count; i++) prsqlda(i, &(demo3_ptr->sqlvar[i-1])); printf("\\n\\n"); for(col_ptr=demo3_ptr->sqlvar, cnt=pos=0; cnt < desc_count; cnt++, col_ptr++) { /* Allow for the trailing null character in C character arrays */ if (col_ptr->sqltype=SQLCHAR) col_ptr->sqllen += 1; /* Get next word boundary for column data and assign buffer position to sqldata */ pos = rtypalign(pos, col_ptr->sqltype); col_ptr->sqldata = &data_buff[pos]; /* Determine size used by column data and increment buffer position */ size = rtypmsize(col_ptr->sqltype, col_ptr->sqllen); pos += size; } EXEC SQL open demo3cursor; for (;;) { fprintf(stderr,"Got Here\\n"); EXEC SQL fetch demo3cursor using descriptor demo3_ptr; fprintf(stderr,"Got Here\\n"); } } prsqlda(index, sp) short int index; register struct sqlvar_struct *sp; { printf(" Column %d: type = %d, len = %d, name = %s\\n", index, sp->sqltype, sp->sqllen, sp->sqlname); } -- Nick Page