On 4/23/08, Joanne Pham <[EMAIL PROTECTED]> wrote:
> 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,
Think of what you are doing, and read what Igor is trying to tell you.
You are mixing two technologies... but are limited by their individual
limitations -- the SQLite shell that implements the dot commands and
the SQL C API that works with the sqlite library.
Try to do all your output compress csv dance in C, or use a more
flexible development environment (Perl, Python, Tcl, whatever) to
accomplish the entire task.
>
> JP
>
>
>
> ----- Original Message ----
> From: Igor Tandetnik <[EMAIL PROTECTED]>
> To: [email protected]
> 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
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users