Hi

Is there any way to handle the different error messages from sqlite without doing strcmp? For example SQLITE_CONSTRAINT?

What I'm doing now is:
id = SELECT id FROM Table WHERE parent=0;
if id = NULL:
        handle parent does not exist

code = INSERT INTO Table(NULL,'a',id);
if (code == SQLITE_CONSTRAINT):
handle data already exists (as that's the only other constraint I can have here)

return data added ok


What I'd like to do is:
code = INSERT INTO Table VALUES(NULL,'a',(SELECT id FROM FileDir WHERE Path='pathname'))

if (code == SQLITE_CONSTRAINT):
        if sqlite_error == SQL_NOT_NULL
                handle parent does not exist
        else if sqlite_error == SQL_EXISTS
                handle entry already exists
return data added ok

I can do that now by using:
rc = sqlite3_exec(db, query, NULL, 0, &zErrMsg);
if (rc == SQLITE_CONSTRAINT)
        if (strcmp(zErrMsg,"table can not be null") == )
                // handle data

Is there really no way to get these errors in another way? So I can avoid use of string compares.


-----------------------------------------------------------------------------
To unsubscribe, send email to [EMAIL PROTECTED]
-----------------------------------------------------------------------------

Reply via email to