Thanks a lot Igor!
But the codes below didn't work too:
char stmt[STMT_LEN];
 char *sqlStmt = &stmt[0];
strcpy(&stmt[0],"output compressTable; mode csv;  select * from compressTable;  
");
 
  sqlSt= sqlite3_exec(pDb,sqlStmt , NULL, 0, &errMsg);
  if (sqlSt != SQLITE_OK ) {
           WXLOGE(LOG_SYSLOG_ON, WX_MODULE_ID_MGMT, WX_SUBMOD_ID_MGMT_MONREPORT,
            "%s: - Error = %s - ",__FUNCTION__, errMsg); 
           sqlite3_free(errMsg);
           bRet= false;
  } 

So how to set the output and mode before executing the select statement.
Thanks a ton,
JP


----- Original Message ----
From: Igor Tandetnik <[EMAIL PROTECTED]>
To: sqlite-users@sqlite.org
Sent: Wednesday, April 23, 2008 4:03:20 PM
Subject: Re: [sqlite] sqlite3_exec return an error message

Joanne Pham <[EMAIL PROTECTED]> wrote:
> I have the following codes to execute the sql file but the error
> message return back that dot(.).
> It seems like sqlite3_exec didn't like ".output wanPerfTableTest".
> So how go to get arround with this command ".output wanPerfTableTest"
>
> strcpy(&stmt[0],".read /tmp/dump_WAN.sql");
> if (bIsConnected) {
>  sqlSt= sqlite3_exec(pDb,stmt , NULL, 0, &errMsg);
>      if (sqlSt != SQLITE_OK ) {
>          ...................
>      }
> }

Dot commands (.output and, for that matter, .read) are interpreted by 
sqlite3 command line utility - not by SQLite engine. They are not valid 
SQL statements. sqlite3_exec complains about .read already, it never 
actually reads the file (so the presence of .output in the file is 
irrelevant).

SQLite won't read the file for you, you will have to do it yourself (and 
probably strip all dot commands from it before passign the contents to 
sqlite3_exec).

Alternatively, just shell out to sqlite3 utility with an appropriate 
command line.

Igor Tandetnik



_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


      
____________________________________________________________________________________
Be a better friend, newshound, and 
know-it-all with Yahoo! Mobile.  Try it now.  
http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to