Results 1 to 5 of 5

Thread: How to get sqlite error message RAISE by trigger

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Mar 2008
    Posts
    141
    Thanks
    10
    Thanked 9 Times in 9 Posts

    Default Re: How to get sqlite error message RAISE by trigger

    Hi,

    what about

    Qt Code:
    1. QString QSqlError::driverText () const
    To copy to clipboard, switch view to plain text mode 

    or maybe you can use

    Qt Code:
    1. int QSqlError::number () const
    To copy to clipboard, switch view to plain text mode 

    and get the sqlite error description from http://www.sqlite.org/c3ref/errcode.html

  2. #2
    Join Date
    Aug 2008
    Posts
    70
    Thanks
    5
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: How to get sqlite error message RAISE by trigger

    Hi Janus,

    In fact, I am using QString QSqlError::text ().

    In documentation, we can read:
    This is a convenience function that returns databaseText() and driverText() concatenated into a single string.
    So, driverText() is not the solution.

    I don't know how to get the message RAISE by the trigger.

    An other idea ?

  3. #3
    Join Date
    Mar 2008
    Posts
    141
    Thanks
    10
    Thanked 9 Times in 9 Posts

    Default Re: How to get sqlite error message RAISE by trigger

    Hi,

    maybe use the sqlite API directly? e.g. const char *sqlite3_errmsg(sqlite3*);
    (http://www.sqlite.org/capi3ref.html#sqlite3_errcode)

    from QSqlDriver:

    Qt Code:
    1. This example retrieves the handle for a connection to sqlite:
    2.  
    3. QSqlDatabase db = ...;
    4. QVariant v = db.driver()->handle();
    5. if (v.isValid() && v.typeName() == "sqlite3*") {
    6. // v.data() returns a pointer to the handle
    7. sqlite3 *handle = *static_cast<sqlite3 **>(v.data());
    8. if (handle != 0) { // check that it is not NULL
    9. ...
    10. }
    11. }
    To copy to clipboard, switch view to plain text mode 


    ... i used that for enabeling extension loading, but I can't find the code right now

    EDit:
    sry, i gave it a try ...guess my C/C++ knowledge is by far not good enought to use something like this. But using the handle to call a c sqlite function did work afair
    Last edited by janus; 17th November 2008 at 21:19.

  4. #4
    Join Date
    Aug 2008
    Posts
    70
    Thanks
    5
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default [RESOLVED] How to get sqlite error message RAISE by trigger

    Thank you for the solution !

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.