ESQL/C retaining cursor ?
Posted in 1993
Topics: Error Codes & Troubleshooting, Connectivity: ESQL/C, 4GL & Embedded SQL
Is it just me, or is the manual for ESQL/C abysmally
insufficient? The index hasn't got ONE word I've been
locking for, but that's probably because the answers
aren't in the manual.
I want to have one function for opening a cursor, one
function for getting the items in order, and one function
to close the cursor again. I can't let the ESQL/C code
call another function, since this is part of a C++
related-objects construction sequence.
The problem is that I don't know how to keep declared cursors.
Obviously you cannot just make them interchangeable with
normal C types.
I do this:
EXEC SQL int f_nr ;
EXEC SQL char f_typ [ 6 ] ;
EXEC SQL char f_typklar [ 22 ] ;
int
start ( void * * position )
{
EXEC SQL
declare my_curs cursor for
select nr , typ , typklar
into :f_nr , :f_typ , :f_typklar
from my_table
; if ( SQLCODE != 0 ) { ... }
EXEC SQL
open my_curs
;
if ( SQLCODE != 0 ) { ... }
/*
* Here comes the skanky part
*
* position = malloc ( sizeof ( my_cursor ) ) ;
if ( ! * position ) { ... }
memcpy ( * position , & ( my_cursor ) , sizeof ( my_cursor ) ) ;
return 0 ;
}
int
get ( void * position , char * item )
{
/*
* ESQL gives a syntax error on the pointer dereference here
*/
EXEC SQL fetch *position ;
if ( SQLCODE != 0 ) { ... }
strncpy ( item , f_typklar , 22 ) ;
return 0 ;
}
I can see why ESQL/C doesn't like this, since it's just taking a
chance on how cursors work (and failing) but HOW DO I DO THIS?
I'll read the group, and summarize to the net if I get any answers
by mail.
Cheers,
/ h+
--
-- Jon W{tte, h+@nada.kth.se, Mac Hacker Deluxe --
Clearly, most humans are not rational beings; they are rationalizing beings.
-- Mel Walker