Hi,
Why not use the "create table if not exists" syntax, that way any error must
be classed as 'other'.
Cheers,
Dave


Ward Analytics Ltd - information in motion
Tel: +44 (0) 118 9740191
Fax: +44 (0) 118 9740192
www: http://www.ward-analytics.com

Registered office address: The Oriel, Sydenham Road, Guildford, Surrey,
United Kingdom, GU1 3SR
Registered company number: 3917021 Registered in England and Wales.


-----Original Message-----
From: sqlite-users-boun...@sqlite.org
[mailto:sqlite-users-boun...@sqlite.org] On Behalf Of Jeffrey Walton
Sent: 21 January 2014 17:54
To: sqlite-users@sqlite.org
Subject: [sqlite] Differentiate between CREATE TABLE failures (Exists vs
Other Failures?)

My startup routine attempts to create all needed tables in my database. For
example:

sqlite3_extended_result_codes(db, 1);
...

int rc;
char* err = NULL;

const char* stmt = "CREATE TABLE users ( "
        "  userid INTEGER PRIMARY KEY AUTOINCREMENT, "
        "  username TEXT,   usergroup TEXT, "
        "  hashalg INTEGER,   salt BLOB,   hmac BLOB, "
        "  verifier BLOB "
        ");";
rc = sqlite3_exec(db, stmt, NULL, NULL, &err);

If the table exists, I receive SQLITE_ERROR as a result even with
sqlite3_extended_result_codes.

Is there a way to get extended error information to differentiate between an
existing table and other errors? Or do I have to parse the error string
returned in `err`?

Thanks in advance?
_______________________________________________
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

Reply via email to