PostgreSQL SELECT after INSERT... where are my data?
-
Hi at all,
I'mg working with PostgreSql (I never it used before).I have a problem after inserting a record.
Eg:QSqlDatabase::database().transaction(); QSqlQuery q; q.prepare("INSERT INTO myTable (name, x, y) VALUES (:name, :x, :y);"); q.bindValue(":name", "myname"); q.bindValue(":x", 10); q.bindValue(":y", 20); bool ok = q.exec(); if (ok) { QSqlDatabase::database().commit(); } else { qDebug() << q.lastError().text(); QSqlDatabase::database().rollback(); }
The query works fine and I don't get any error.
With pgAdmin I can see the data but not on my application.
I've created a button to requery the table but no way...If I restart the application I can see the inserted records!
What I'm missing ?!?Thank you!
-
@addebito said in PostgreSQL SELECT after INSERT... where are my data?:
not on my application.
How do you check? If you see it with psql/pgadmin then it was successfully inserted.
-
@Christian-Ehrlicher yes, you are right. It's successfully inserted but why in my application I don't see these inserted records after a new query like this?
SELECT * FROM myTable;
As mentionend before, I see these records If I close and restart the application.
There isn't an option on the connection... or inside QSqlDatabase? -
@Christian-Ehrlicher I'm sorry, the problem could be on visualization data.I've introduce the QSortFilterProxyModel.
-
@Christian-Ehrlicher I found the problem.
On my subclass I'd forgotten the "beginRemoveRows" ... "endRemoveRows".
Anyway, thank you for your reply.