
Originally Posted by
nnidza
CREATE TABLE "Blood"
(
"GroupID" int4 NOT NULL,
...
)
WITHOUT OIDS;
ALTER TABLE "Blood" OWNER TO postgres;
Try:
CREATE TABLE "Blood"
(
"GroupID" serial NOT NULL,
...
)
...
CREATE TABLE "Blood"
(
"GroupID" serial NOT NULL,
...
)
...
To copy to clipboard, switch view to plain text mode
and:
{
record.setGenerated( "GroupID", false );
}
void Krv::beforeInsertRec(QSqlRecord &record)
{
record.setGenerated( "GroupID", false );
}
To copy to clipboard, switch view to plain text mode
This way PostgreSQL will use a sequence to generate GroupIDs in a safe manner.
It always got the id=0 value? Can someone help???
The problem is that you probably don't submit changes to the database, so every time you call generateId() is operates on an empty table, but first make sure that the query is correct.
See QSqlTableModel::setEditStrategy().
Bookmarks