[comp.databases] Informix ESQL/C: techincal question

heman@ghp.UUCP (Heman Choy) (04/24/91)

Question: How can I make a cursor-identifier dynamic on the DECLARE and
FETCH statment in Informix ESQL/C?

I am writing Informix ESQL/C applications and need to make the
cursor-identifier variable.  For example, in

$declare curs1 cursor for select ....

how can I make curs1 a variable in my function, so that I can use the
same function for various cursors?  Is it possible to do that at all?

I have tried going into the generated C code from esql and modified
the _SQCURSOR identifier into an array, and pass an index number to
the function to specify the cursor, but no success. i.e.:

#include <sqlhdr.h>
static _SQCURSOR _SQ1[10], _SQ2, ...
/* originally: static _SQCURSOR _SQ1, SQ2, ... */
:
void fn(char *cur_id, int idx)
{
:
strcpy(str,"select field1 from db_view"); 
				/* db_view is created elsewhere */
_iqprepare( &_SQ1[idx], str );
_iqddclcur( &_SQ1[idx], cur_id, 32 );
			/* cur_id is suplied when fn is called */
_iqopen( &SQ1[idx], ... );
}

Your advice is much appreciated!