From: unbewusst.sein@... (=?ISO-8859-1?Q?Une_B=E9v?= =?ISO-8859-1?Q?ue?=) Date: 2007-10-14T23:15:05+09:00 Subject: SQLite3::SQLException: SQL logic error or missing database I've read a lot of people reporting probs with SQLite3 and this error message : SQLite3::SQLException: SQL logic error or missing database my setup : sqlite3-ruby latest ruby 1.8.6 (2007-03-13 patchlevel 0) [powerpc-darwin8.9.0] Mac OS X 10.4.10 here is my script : ---------------------------------------------------------------------- #! /usr/bin/env ruby begin; require 'rubygems'; rescue LoadError; end require 'sqlite3' DB = SQLite3::Database.new( "devicephonebook_create_5_bis.db" ) DB.create_function( "get_zy_string", 1 ) do | func, value | if value.nil? func.result = "***ZY***NULL" else func.result = "***ZY***#{value.to_s}" end end DB.create_function( "get_py_string", 1 ) do | func, value | if value.nil? func.result = "***PY***NULL" else func.result = "***PY***#{value.to_s}" end end DB.create_function( "get_first_char", 1 ) do | func, value | if value.nil? func.result = 20 else func.result = value[0] end end sql = "INSERT INTO devicephonebook ( lastName, firstName ) VALUES( 'Smith','John' );" DB.execute( sql ) ---------------------------------------------------------------------- which returns : # = > SQLite3::SQLException: SQL logic error or missing database Obviously i'm sure the file database does exist. the sql content of the database : ---------------------------------------------------------------------- BEGIN TRANSACTION; CREATE TABLE devicephonebook( UID INTEGER PRIMARY KEY AUTOINCREMENT ,lastName TEXT NOT NULL DEFAULT(''),firstName TEXT NOT NULL DEFAULT(''), lastChar INTEGER , fullLastName TEXT , ZYFLName TEXT , PYFLName TEXT , hasPhoto INTEGER DEFAULT(0) , timeStamp TEXT); CREATE INDEX nameIndex ON devicephonebook (PYFLName, lastName, firstName, lastChar, hasPhoto); CREATE TRIGGER DELETE_EXT_TRIGGER AFTER DELETE ON devicephonebook BEGIN DELETE FROM extraphonebook WHERE extraphonebook.UID = OLD.UID; SELECT delete_from_cache(OLD.UID); END; CREATE TRIGGER INSERT_PBK_TRIGGER AFTER INSERT ON devicephonebook BEGIN UPDATE devicephonebook SET fullLastName=NEW.lastName||NEW.firstName ,ZYFLName=get_zy_string(NEW.lastName||NEW.firstName) ,PYFLName=get_py_string(NEW.lastName|| NEW.firstName) ,lastChar=get_first_char(NEW.lastName|| NEW.firstName) WHERE UID=NEW.UID; END; COMMIT; ---------------------------------------------------------------------- this database structure is coming from a mobile phone (e2831) and works well on my mobile )) clearly i don't understand why this doesn't work. also i've try to change the INSERT to insert all the values in a row, this doesn't change anything... -- Une B�vue