Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Call for Presentations - Qt World Summit

    Unsolved How can I get value of inout parameter from PostgreSQL procedure call?

    General and Desktop
    postgresql
    3
    6
    412
    Loading More Posts
    • 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.
    • O
      OpenGL last edited by

      I have code like this

      QString my_str = "call my_proc(null,null);";
      QSqlQuery my_query(d);
      my_query.exec(my_str);
      

      And it works, it calls the postgresql procedure

      procedure my_proc(value int, return_value INOUT int);
      

      But how can I get the value of the return_value parameter?
      When I try to get the value from

      query.record 
      

      it seems the value is always 0.
      So I guess I'm missing something important here.

      Is there an example of how to do this for Postgresql?

      (note: it seems I can not call procedures with bind variables, else I would have tried that).

      JonB 1 Reply Last reply Reply Quote 0
      • JonB
        JonB @OpenGL last edited by JonB

        @OpenGL said in How can I get value of inout parameter from PostgreSQL procedure call?:

        (note: it seems I can not call procedures with bind variables, else I would have tried that).

        I don't know anything about PostgreSQL/procedure calls. But as far as I know you must bind to a variable to get an OUT parameter back. So show what you tried for the prepare/bind()?

        1 Reply Last reply Reply Quote 3
        • O
          OpenGL last edited by

          Prepare/bind does not work with postgres procedures, so I have to do it some other way. And I have no idea how.

          SGaist 1 Reply Last reply Reply Quote 0
          • SGaist
            SGaist Lifetime Qt Champion @OpenGL last edited by

            Hi,

            @OpenGL said in How can I get value of inout parameter from PostgreSQL procedure call?:

            Prepare/bind does not work with postgres procedures, so I have to do it some other way. And I have no idea how.

            Can you provide more information about that ?
            Do you have a simple example of procedure that can be tested ?

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            O 1 Reply Last reply Reply Quote 0
            • O
              OpenGL @SGaist last edited by

              @SGaist said in How can I get value of inout parameter from PostgreSQL procedure call?:

              Hi,

              @OpenGL said in How can I get value of inout parameter from PostgreSQL procedure call?:

              Prepare/bind does not work with postgres procedures, so I have to do it some other way. And I have no idea how.

              Can you provide more information about that ?
              Do you have a simple example of procedure that can be tested ?

              Hello, sorry for late reply.
              I had a discussion about it here https://forum.qt.io/topic/120460/minimal-sql-program-that-fails-what-is-wrong-with-it/2
              An minimal example is included there with a procedure that failes to be prepared with the prepare command.

              JonB 1 Reply Last reply Reply Quote 0
              • JonB
                JonB @OpenGL last edited by JonB

                @OpenGL
                I'm not defending this other than as a nasty hack. But if what you say is true, and you are stuck looking for a workaround: you can pass input parameters by interpolating them literally into the call() statement, and you can receive output parameters by returning them via a SELECT statement at the end of a call()ed procedure. Assuming you get a result set back from the call() which the driver can retrieve.

                1 Reply Last reply Reply Quote 0
                • First post
                  Last post