Re: [sqlite] How to use sqlite3_exec() to execute SQL command with Unicode text?

2009-10-03 Thread bigboss97

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, , );
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_NullCallback))
){
if( 0==nCallback ){
  for(i=0; ierrMask)==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


Re: [sqlite] How to use sqlite3_exec() to execute SQL command with Unicode text?

2009-09-29 Thread Kees Nuyt
On Tue, 29 Sep 2009 07:07:54 -0700 (PDT), bigboss97
 wrote:

>
>My program is using sqlite3_exec() to run SQL command which has the type of
>char*. Now I want to allow unicode in my DB. What do I have to change?
>Obviously, sqlite3_exec() won't work any more.
>
>Phuoc

This page tells it all in a nutshell:
http://www.sqlite.org/c3ref/stmt.html
-- 
  (  Kees Nuyt
  )
c[_]
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


[sqlite] How to use sqlite3_exec() to execute SQL command with Unicode text?

2009-09-29 Thread bigboss97

My program is using sqlite3_exec() to run SQL command which has the type of
char*. Now I want to allow unicode in my DB. What do I have to change?
Obviously, sqlite3_exec() won't work any more.

Phuoc

-

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--tp25663732p25663732.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