[REBOL] Re: SQLite - pointer to function question
From: nitsch-lists:netcologne at: 1-Mar-2004 22:05
Am Sonntag, 29. Februar 2004 20:55 schrieben Sie:
> Hello rebol-list,
>
> I've been playing a bit with SQLite.dll ( http://sqlite.org ) and
> even I'm not expert in this filed at all, I manage to open db and
> execute SQL commands using this DLL. But the problem is that if you
> want to use SELECT command you must send pointer to a callback
> function which should be evaluated for each result row.
>
> Is there any change to get a pointer to a Rebol function?
>
No AFAIK.
BUT youmay read the docs further and note a second interface which works
callback-free ;)
http://www.sqlite.org/c_interface.html
2.0 Accessing Data Without Using A Callback Function
The sqlite_exec routine described above used to be the only way to retrieve
data from an SQLite database. But many programmers found it inconvenient to
use a callback function to obtain results. So beginning with SQLite version
2.7.7, a second access interface is available that does not use callbacks.
The new interface uses three separate functions to replace the single
sqlite_exec function.
typedef struct sqlite_vm sqlite_vm;
int sqlite_compile(
sqlite *db, /* The open database */
const char *zSql, /* SQL statement to be compiled */
const char **pzTail, /* OUT: uncompiled tail of zSql */
sqlite_vm **ppVm, /* OUT: the virtual machine to execute zSql */
char **pzErrmsg /* OUT: Error message. */
);
int sqlite_step(
sqlite_vm *pVm, /* The virtual machine to execute */
int *pN, /* OUT: Number of columns in result */
const char ***pazValue, /* OUT: Column data */
const char ***pazColName /* OUT: Column names and datatypes */
);
int sqlite_finalize(
sqlite_vm *pVm, /* The virtual machine to be finalized */
char **pzErrMsg /* OUT: Error message */
);
The strategy is to compile a single SQL statement using sqlite_compile then
invoke sqlite_step multiple times, once for each row of output, and finally
call sqlite_finalize to clean up after the SQL has finished execution.
//and now have fun ;)
//-Volker