thanks. I tried that, but I still got back "constraint failed" rather than my RAISE message. Since you say it should work, I probably did something wrong. I'll look at it again.
On Jul 1, 2009, at 3:59 PM, Simon Slavin wrote: > > On 1 Jul 2009, at 8:19pm, James Gregurich wrote: > >> Would there be a way to identify the offending constraint if >> "SQLITE_CONSTRAINT" is returned? >> >> >> sqlite3_errmsg is just telling me "constraint failed"...which is of >> limited usefulness. > > Instead of the constraint, you could define a trigger, and use the > 'RAISE' form to supply your own error message. Here's an example: > > CREATE TRIGGER authors_books_insert BEFORE INSERT ON books > FOR EACH ROW BEGIN > SELECT RAISE(ROLLBACK, 'Attempt to add a book with an author > number which is not valid.') > WHERE (SELECT id FROM authors WHERE id = new.author) IS NULL; > END > > You get back exactly the error message you put in. > > Simon. > _______________________________________________ > sqlite-users mailing list > sqlite-users@sqlite.org > http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users