Re: ESQL/C Cursors
Posted in 1994
Topics: SQL Development & Query Writing, Error Codes & Troubleshooting, Connectivity: ESQL/C, 4GL & Embedded SQL, Migration, Import/Export & Data Conversion
Hi Rob, >So the question is: >Does anyone know how to declare a scroll cursor in ESQL/C such that it can be >stored into a C struct and passed around? I have been unable to find a way to >do this through standard ESQL/C The way is to predeclare a cursor array. I have attached a 'C' program template which i extracted from a program i wrote to manage dynamic Sql operations (insert,select..). > I'm leary of messing directly with the .c file >I get out of the esql command. Watch out for version changes Madi. --------------------------------- #define NCURS 100 typedef struct { /* table entry: */ . . _SQCURSOR tabcursor; /* select Cursor for this table */ _SQCURSOR inscursor; /* insert Cursor for this table */ struct sqlda *tdesc; /* descriptor for this table */ . . } TABITM; static TABITM tabarr[NCURS]; /* allocate TABITM for NCURS */ prpare_cursor (tabname,np) char *tabname; TABITM *np; { . . .stuff deleted . . sprintf (tmpbuf,"select * from %s",tabname); /** $prepare sid from $tmpbuf; **/ _iqprepare (&np->tabcursor, tmpbuf); if (sqlca.sqlcode < 0) { m_sql_errlog ("prep sid"); return (0); } /** $describe sid into np->tdesc; **/ _iqdscribe (&np->tabcursor, &np->tdesc); if (sqlca.sqlcode < 0) { m_sql_errlog ("desc sid"); return (0); } if (sqlca.sqlcode > 0 && sqlca.sqlcode != SQ_SELECT) { m_sql_errlog ("Statement is not a SELECT STATEMENT"); return (0); } . . .stuff deleted . . } insert_cursor (np) TABITM *np; { . . _iqxecute(&np->inscursor, 0, (char *) 0, np->tdesc, (char *) 0); if (sqlca.sqlcode < 0) { m_sql_errlog ("execute insert"); return (0); } . . } +---------------------------+--------------------------+ | G.T.Madavan, | e-mail: gtmad@smi.mn.org | | Systems Migration Inc., | Phone : (612) 890-0040 | | Burnsville, MN, U.S.A | Fax : (612) 890-0966 | +---------------------------+--------------------------+