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
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users