[Qt-interest] QSqlRecord pqsql & INSERT

Ross Driedger ross at earz.ca
Thu Dec 24 18:17:22 CET 2009


On Wed, 23 Dec 2009 23:43:08 -0500, <qt-interest-request at trolltech.com>  
wrote:


> I am trying to insert a record into a QSqlTableModel (Postgres DB Table).
> The first column is a serial primary key. setRecord and submitAll fails
> with the message that the serial unique constraint failed.
> I tried to set the record's field to setAutoValue(true) or
> setGenerated(false) but it always failed.
> The postgres docs say I could use DEFAULT in an insert statement. But if
> I use DEFAULT in the record it is treated as a string.
> Does anyone know how I could insert a record with a serial field?

Hi Jan,

This solution has nothing to do with Qt.

Have you implemented SEQUENCE objects in your database?  I've used them  
with great success.

Ross


-- 
"Life without music would be a mistake. "
Friedrich Nietzsche

Ross Driedger
ross_at_earz.ca



More information about the Qt-interest-old mailing list