ESQL/C and Online 7 table fragmentation
Posted in 1996
Topics: Error Codes & Troubleshooting, Connectivity: ESQL/C, 4GL & Embedded SQL
Hi, We are running a ESQL/C program to access to a Informix Online 7.1 server. Some tables in the database are fragmented of 3 hard disks. We encounter problems when trying to SELECT rows from such a table. When we execute this request from isql, the 3 hard disks work together (this is confirmed by a look at the result of a sar command). But when we execute the same request from our ESQL/C program, the 3 hard disks are working one after the other (the sar command show here that the disks are working sequentially). When we build and run the demo samples supply with ESQL/C (modified to execute the previous request on our database), the disks work at the same time (in this case, the SELECT is issued throught a non dynamic DECLARE ... SELECT ... INTO .../OPEN/FETCH/CLOSE suite of commands and there no using descriptor clause in the open). Here is a simplified version of our program. We compile it on an HP/UX 9.04 server. Any suggestions or answer to this problem would be welcome. Thanks in advance. Roger FLATTIN CORNUT Informatique /********************************************************************/ #include <malloc.h> #include <stdio.h> EXEC SQL INCLUDE sqlca; EXEC SQL INCLUDE sqlda; EXEC SQL INCLUDE sqltypes; void throw_error() { char sqlerrtxt[121]; rgetmsg( sqlca.sqlcode, sqlerrtxt, 120 ); fprintf( stderr, "sqlcode = %d, %s\\n", sqlca.sqlcode, sqlerrtxt ); exit( 1 ); } void execute_select() { EXEC SQL BEGIN DECLARE SECTION; char q_string[256]; EXEC SQL END DECLARE SECTION; int i; struct sqlda *q_desc, *dyn_da; strcpy( q_string, "select code_constituant, code_site, moy_horaire_jour, \\ date_mesure from horaire where code_constituant like ? and num_site like ?" ); EXEC SQL prepare sqlobj from :q_string; if( sqlca.sqlcode < 0 ) throw_error(); dyn_da = (struct sqlda *) malloc( sizeof(struct sqlda) ); dyn_da->sqld = 2; for( i = 0; i < 2 ; i++ ) { dyn_da->sqlvar[i].sqllen = 3; dyn_da->sqlvar[i].sqltype = CCHARTYPE; dyn_da->sqlvar[i].sqldata = (char *) malloc( 4 ); dyn_da->sqlvar[i].sqlind = (short *) malloc( sizeof(short) ); *dyn_da->sqlvar[i].sqlind = 0; } strcpy( dyn_da->sqlvar[0].sqldata, "08%" ); strcpy( dyn_da->sqlvar[1].sqldata, "25%" ); EXEC SQL describe sqlobj into q_desc; if( sqlca.sqlcode < 0 ) throw_error(); for( i = 0; i < q_desc->sqld; i++ ) { q_desc->sqlvar[i].sqllen = 10; q_desc->sqlvar[i].sqltype = CFIXCHARTYPE; q_desc->sqlvar[i].sqldata = (char *) malloc( 11 ); q_desc->sqlvar[i].sqlind = (short *) malloc( sizeof(short) ); *q_desc->sqlvar[i].sqlind = 0; } EXEC SQL declare sqlcurs cursor with hold for sqlobj; if( sqlca.sqlcode < 0 ) throw_error(); EXEC SQL open sqlcurs using descriptor dyn_da; if( sqlca.sqlcode < 0 ) throw_error(); for(;;) { EXEC SQL fetch sqlcurs using descriptor q_desc; if( sqlca.sqlcode != 0 ) break; for( i = 0; i < q_desc->sqld; i++ ) { q_desc->sqlvar[i].sqldata[ q_desc->sqlvar[i].sqllen ] = 0; printf( "sqldata[i]=%s\\n", i, q_desc->sqlvar[i].sqldata ); } } printf( "sqlcode = %d\\n", sqlca.sqlcode ); EXEC SQL close sqlcurs; EXEC SQL free sqlcurs; EXEC SQL free sqlobj; } main() { EXEC SQL database bdqa_v7; if( sqlca.sqlcode < 0 ) throw_error(); execute_select(); EXEC SQL close database; } /********************************************************************/ -------------------------------------------------------------- CORNUT Informatique SA Client/Server & SQL RDBMS BP 702 - 42950 St Etienne cedex 9 http://www.cornut.fr/ France email: info@cornut.fr