On Mon, May 9, 2016 at 3:48 PM, Dominique Devienne <ddevienne at gmail.com> 
wrote:
> On Mon, May 9, 2016 at 3:46 PM, Dominique Devienne <ddevienne at gmail.com> 
> wrote:
>> On Mon, May 9, 2016 at 3:21 PM, Cecil Westerhof <cldwesterhof at gmail.com> 
>> wrote:
>>> [...] Is there a way to get this information?
>>
>> Just name your CHECK constraint, and use a recent version of SQLite. --DD

sqlite> create table tt (v check (v in (0, 1)));
sqlite> insert into tt values (2);
Error: CHECK constraint failed: tt

Note that w/o a *named* constraint, it seems to just show the table name.
And if you meant a programmatic way to know the failure is a check
constraint, there's

SQLITE_CONSTRAINT from https://sqlite.org/c3ref/c_abort.html
SQLITE_CONSTRAINT_CHECK from https://sqlite.org/c3ref/c_abort_rollback.html

but there's no way AFAIK to get the violated constraint name via an API,
except by parsing the error message (subject to change I guess...),
nor to reliably know it's a constraint name as opposed to a table name. --DD

Reply via email to