Thank you for the link. Then I started solving the callback problem. After a bit research, I found out that I could end up with a new exec() function. So I took the original exec() and modified it. It's working, no guaratee :-D
int sqlite3_exec16( sqlite3 *db, /* The database on which the SQL executes */ const short *zSql, /* The SQL(16) to be executed */ sqlite3_callback16 xCallback, /* Invoke this callback routine */ void *pArg, /* First argument to xCallback() */ short **pzErrMsg /* Write error messages here */ ){ int rc = SQLITE_OK; const short *zLeftover; sqlite3_stmt *pStmt = 0; short **azCols = 0; int nRetry = 0; int nCallback; if( zSql==0 ) return SQLITE_OK; while( (rc==SQLITE_OK || (rc==SQLITE_SCHEMA && (++nRetry)<2)) && zSql[0] ){ int nCol; short **azVals = 0; pStmt = 0; rc = sqlite3_prepare16_v2(db, zSql, -1, &pStmt, &zLeftover); assert( rc==SQLITE_OK || pStmt==0 ); if( rc!=SQLITE_OK ){ continue; } if( !pStmt ){ /* this happens for a comment or white-space */ zSql = zLeftover; continue; } nCallback = 0; nCol = sqlite3_column_count(pStmt); azCols = sqliteMalloc(2*nCol*sizeof(const short *) + 1); if( azCols==0 ){ goto exec_out; } while( 1 ){ int i; rc = sqlite3_step(pStmt); /* Invoke the callback function if required */ if( xCallback && (SQLITE_ROW==rc || (SQLITE_DONE==rc && !nCallback && db->flags&SQLITE_NullCallback)) ){ if( 0==nCallback ){ for(i=0; i<nCol; i++){ azCols[i] = (short *)sqlite3_column_name16(pStmt, i); } nCallback++; } if( rc==SQLITE_ROW ){ azVals = &azCols[nCol]; for(i=0; i<nCol; i++){ azVals[i] = (short *)sqlite3_column_text16(pStmt, i); } } if( xCallback(pArg, nCol, azVals, azCols) ){ rc = SQLITE_ABORT; goto exec_out; } } if( rc!=SQLITE_ROW ){ rc = sqlite3_finalize(pStmt); pStmt = 0; if( rc!=SQLITE_SCHEMA ){ nRetry = 0; zSql = zLeftover; while( iswspace((unsigned char)zSql[0]) ) zSql++; } break; } } sqliteFree(azCols); azCols = 0; } exec_out: if( pStmt ) sqlite3_finalize(pStmt); if( azCols ) sqliteFree(azCols); rc = sqlite3ApiExit(0, rc); if( rc!=SQLITE_OK && rc==sqlite3_errcode(db) && pzErrMsg ){ *pzErrMsg = sqlite3_malloc(1+strlen(sqlite3_errmsg16(db))); if( *pzErrMsg ){ strcpy(*pzErrMsg, sqlite3_errmsg16(db)); } }else if( pzErrMsg ){ *pzErrMsg = 0; } assert( (rc&db->errMask)==rc ); return rc; } Kees Nuyt wrote: > > > This page tells it all in a nutshell: > http://www.sqlite.org/c3ref/stmt.html > -- > ( Kees Nuyt > ----- ........................ www.folksfun.com ........................ -- View this message in context: http://www.nabble.com/How-to-use-sqlite3_exec%28%29-to-execute-SQL-command-with-Unicode-text--tp25663732p25728190.html Sent from the SQLite mailing list archive at Nabble.com. _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users