Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. PostgreSQL SELECT after INSERT... where are my data?
Forum Updated to NodeBB v4.3 + New Features

PostgreSQL SELECT after INSERT... where are my data?

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 2 Posters 700 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    addebito
    wrote on 17 Apr 2020, 15:37 last edited by addebito
    #1

    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!

    1 Reply Last reply
    0
    • C Offline
      C Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on 17 Apr 2020, 16:06 last edited by
      #2

      @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.

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      A 3 Replies Last reply 17 Apr 2020, 16:16
      1
      • C Christian Ehrlicher
        17 Apr 2020, 16:06

        @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.

        A Offline
        A Offline
        addebito
        wrote on 17 Apr 2020, 16:16 last edited by
        #3

        @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?

        1 Reply Last reply
        0
        • C Christian Ehrlicher
          17 Apr 2020, 16:06

          @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.

          A Offline
          A Offline
          addebito
          wrote on 17 Apr 2020, 16:33 last edited by
          #4

          @Christian-Ehrlicher I'm sorry, the problem could be on visualization data.I've introduce the QSortFilterProxyModel.

          1 Reply Last reply
          0
          • C Christian Ehrlicher
            17 Apr 2020, 16:06

            @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.

            A Offline
            A Offline
            addebito
            wrote on 17 Apr 2020, 17:11 last edited by
            #5

            @Christian-Ehrlicher I found the problem.
            On my subclass I'd forgotten the "beginRemoveRows" ... "endRemoveRows".
            Anyway, thank you for your reply.

            1 Reply Last reply
            1

            1/5

            17 Apr 2020, 15:37

            • Login

            • Login or register to search.
            1 out of 5
            • First post
              1/5
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved