Results 1 to 5 of 5

Thread: Insert record into PostgreSQL table using default DB values

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Insert record into PostgreSQL table using default DB values

    Call QSqlTableModel::insertRows(), call setData() a number of times to set what you want in the new row (don't set the id column), move to another row or submitAll() the row (depends on edit strategy). This is all straight out of the manual, nothing tricky.

    If you are having problems, provide us with some idea of what you are actually doing, what you expect to see, and what you actually see.

  2. #2
    Join Date
    Jan 2010
    Location
    Poland Warsaw
    Posts
    25
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Insert record into PostgreSQL table using default DB values

    Call QSqlTableModel::insertRows(), call setData() a number of times to set what you want in the new row (don't set the id column), move to another row or submitAll() the row (depends on edit strategy). This is all straight out of the manual, nothing tricky.
    This method doesn't work.

    For now I use:
    Qt Code:
    1. void DBEngine::beforeInsertRec(QSqlRecord &record)
    2. {
    3. record.setGenerated(0, false);
    4. }
    To copy to clipboard, switch view to plain text mode 

    slot connected to beforeInsert(QSqlRecord &record) signal to set ID field to not be generated in sql query.

    I've found this solution in this forum.

    Thanks.

Similar Threads

  1. Replies: 3
    Last Post: 11th December 2010, 20:28
  2. Fast insert record into MySql
    By weixj2003ld in forum Qt Programming
    Replies: 3
    Last Post: 15th July 2010, 09:08
  3. Replies: 2
    Last Post: 13th April 2010, 16:50
  4. Import PostgreSQL Values to SQLITE
    By raphaelf in forum Newbie
    Replies: 2
    Last Post: 24th May 2007, 17:56
  5. Import PostgreSQL Values to QT
    By raphaelf in forum Newbie
    Replies: 8
    Last Post: 23rd May 2007, 09:09

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.