I've also tried also using it in an SQL transaction (eg a batch import script), 
but SQLite doesn't allow it. So, in a transaction, one approach I've used is to 
create a temp table, a temp trigger and then insert some test data just to be 
able to use the raise function to abort the transaction and post an error back.

Another work around is to create a Log table and populate it with error 
messages that should result from any dat that is outside the desired 
constraints, eg:

create table if not exists "Log"
(       ID integer primary key not null
,       "Date" date not null
,       "Error" text not null collate nocase
)
;
insert into "Log" ("Date", "Error")
select
        datetime('now')
,       'columnValue ' || columnValue || ' is above maximum ' || maximumAllowed 
|| ' in row ' || rowid
from Source
where new.columnValue > maximumAllowed
;

But again, you have to duplicate the logic that is already in your constraints, 
which is frustrating and error prone.

Thanks,
Tom

Tom Brodhurst-Hill
BareFeetWare

--
iPhone/iPad/iPod and Mac software development, specialising in databases
develo...@barefeetware.com
--
Twitter: http://twitter.com/barefeetware/
Facebook: http://www.facebook.com/BareFeetWare

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

Reply via email to