Doing some experimenting in my application and having trouble with an 
"INSERT OR REPLACE" statement.

SQLite version 3.5.9

Table schema:

CREATE TABLE DDS (FileId INTEGER PRIMARY KEY, _ModTime INTEGER, _CreTime 
INTEGER , _vtresult INTEGER, _md5 BINARY, _sha1 BINARY, _sha256 BINARY, 
_StabString__ TEXT, _caInt INTEGER, _caStr TEXT, _caBin BINARY);

SQL statement:

INSERT OR REPLACE INTO DDS 
(_ModTime,_CreTime,_vtresult,_md5,_sha1,_sha256,_StabString__,_caInt,_caStr,_caBin,
 
FileId) VALUES(?,?,?,?,?,?,?,?,?,?,?);

When I run Prepare16 (statement is UNICODE) I get an error 
SQLITE_ERROR.  The error text is: "near "REPLACE": syntax error".

If I remove the "OR REPLACE" Prepare16 call succeeds.

If I run this from in the command line tool replacing all the "?" with 
appropriate values, it succeeds.  I was using the 3.5.9 command line tool.

For my application, I've regenerated the amalgamated source and am 
building with a number of options to reduce size and control behavior.  
They are:

-DTHREADSAFE=1
-DSQLITE_OMIT_FLOATING_POINT=1
-DSQLITE_ENABLE_MEMORY_MANAGEMENT=1
-DSQLITE_OMIT_AUTHORIZATION=1
-DSQLITE_OMIT_AUTOINCREMENT=1
-DSQLITE_OMIT_AUTOVACUUM=1
-DSQLITE_OMIT_BLOB_LITERAL=1
-DSQLITE_OMIT_COMPLETE=1
-DSQLITE_OMIT_COMPOUND_SELECT=1
-DSQLITE_OMIT_CONFLICT_CLAUSE=1
-DSQLITE_OMIT_DATETIME_FUNCS=1
-DSQLITE_OMIT_EXPLAIN=1
-DSQLITE_OMIT_FOREIGN_KEY=1
-DSQLITE_OMIT_INTEGRITY_CHECK=1
-DSQLITE_OMIT_LOAD_EXTENSION=1
-DSQLITE_OMIT_MEMORYDB=1
-DSQLITE_OMIT_PROGRESS_CALLBACK=1
-DSQLITE_OMIT_REINDEX=1
-DSQLITE_OMIT_SUBQUERY=1
-DSQLITE_OMIT_TEMPDB=1
-DSQLITE_OMIT_TCL_VARIABLE=1
-DSQLITE_OMIT_TRIGGER=1
-DSQLITE_OMIT_VIEW=1
-DSQLITE_OMIT_VIRTUALTABLE=1
-DSQLITE_OMIT_FAULTINJECTOR=1

SQLITE_OMIT_CONFLICT_CLAUSE has me a bit worried, but as far as I can 
see, it has been added for future work and doesn't do anything yet.  It 
is not present in parse.y.  It seems to only appear in one of the TCL 
test script files.  Obviously, I will remove this before adding my new 
"INSERT OR REPLACE" stuff to production code.

I went so far as to step through the parsing of the statement.  It is 
failing when evaluating the "REPLACE" token.  Before I really start 
digging into this I wanted to see if anyone else has any experience that 
might help. 

1) Is the syntax correct?  I suspect so because it worked with the 
command line tool, unless there is a typo that eludes me.
2) Can anyone point to a SQLITE compile option that would interfere with 
the "REPLACE" keyword?

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

Reply via email to