Home
Highly Reusable Software By activity User Interface Text Strings Math Processing
Stored Data
Communications
Hard World File System
|
#License - #Source code - #Example Use -
#include <librock/data.h> void * /* a connection ID for use in other calls */ librock_dbi_open( const char *pszParams, /* blank-separated list of parameters. First is driver name */ char **ppaszErr /* stores a librock_astring error message */ );
The implementation of librock_dbi_exec must intercept the special query "SHOW TABLES" and perform the appropriate action so that librock_db_fetch_row will return a list of tables.
If the caller expects to have more than one query open simultaneously, (i.e. a call to librock_dbi_exec() before finishing the with results of a previous query) it must call librock_dbi_open() for each simultaneous query. (The implementation may pool such connections, but is not required to.)
Based on compile-time flags, drivers can be disabled by #define librock_dbi_DRIVER_open librock_dbi_fail_open
As of 2002-06-14, the driver supported is 'odbc'. The paramete for open is the DSN.
Typical use is
char *err = 0; void *idConn = librock_dbi_open("odbc DRIVER={Microsoft Text Driver (*.txt; *.csv)};DefaultDir=g:\\reuse\\db\\;",&err); void *idStmt; if (!idConn) { printf("%s\n",err); return -1; } idStmt = librock_dbi_exec(idConn,"SELECT * FROM tablename",&err); if (idStmt) { const char **pCols; int n; int i; while(1) { librock_dbi_fetch_row(idStmt,&pCols,&n,&err); if (err && !strncmp(err,"I-106-",5)) { librock_dbi_fetch_row(idStmt,0,0,&err); break; } i =0; while(i < n) { if (i) { printf("\t%s",pCols[i]); } else { printf("%s",pCols[i]); } i++; } printf("\n"); } } librock_dbi_close(idConn,&err); librock_astrfree(&err);
librock_wordcmp librock_dbi_odbc_open
Copyright 1998-2002 Forrest J. Cavalier III, http://www.mibsoftware.com Licensed under BSD-ish license, NO WARRANTY. Copies must retain this block. License text in <librock/license/librock.txt> librock_LIDESC_MD5=f2a00374df769e694451262ac9df1336
Verbatim copying and distribution of this generated page is permitted in any medium provided that no changes are made.
(The source of this manual page may be covered by a more permissive license which allows modifications.)
Want to help? We welcome comments, patches. -- Need help? Request paid support.