Results 1 to 3 of 3

Thread: How to get the return value of a 'returning clause' using PostgreSQL?

  1. #1
    Join Date
    Jan 2008
    Location
    Davao City, Philippines
    Posts
    77
    Thanks
    16
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default How to get the return value of a 'returning clause' using PostgreSQL?

    Good afternoon!

    Using PostgreSQL my query looks like this:

    Qt Code:
    1. UPDATE nummernkreise SET wert = wert+1 WHERE name = 'Angebot' RETURNING wert;
    To copy to clipboard, switch view to plain text mode 

    The query returns the updated value of 'wert'.

    In Qt (4.8.4) I have tried

    Qt Code:
    1. query.prepare( "UPDATE nummernkreise SET wert = wert+1 WHERE name = :Name RETURNING wert" );
    2. query.bindValue( ":Name", m_form );
    3. query.exec();
    To copy to clipboard, switch view to plain text mode 

    Any idea how to get the updated content of 'wert' returned by this query?

    Guenther
    Last edited by gboelter; 9th January 2014 at 11:06.
    DavaoSOFT, the home of ERPel
    ERPel, das deutsche Warenwirtschaftssystem fuer LINUX
    http://www.davaosoft.com

  2. #2
    Join Date
    Mar 2008
    Location
    Kraków, Poland
    Posts
    1,536
    Thanked 284 Times in 279 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to get the return value of a 'returning clause' using PostgreSQL?

    Read carefully about QSqlQuery::bindValue. It have 3 parameters.

  3. The following user says thank you to Lesiok for this useful post:

    gboelter (11th January 2014)

  4. #3
    Join Date
    Jan 2008
    Location
    Davao City, Philippines
    Posts
    77
    Thanks
    16
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How to get the return value of a 'returning clause' using PostgreSQL?

    Quote Originally Posted by Lesiok View Post
    Read carefully about QSqlQuery::bindValue. It have 3 parameters.
    Thanks Lesiok,

    I have never recogniced the third parameter of QSqlQuery::bindValue, but now it's working.

    Regards

    Guenther
    DavaoSOFT, the home of ERPel
    ERPel, das deutsche Warenwirtschaftssystem fuer LINUX
    http://www.davaosoft.com

Similar Threads

  1. Replies: 1
    Last Post: 2nd January 2013, 09:48
  2. Replies: 2
    Last Post: 9th March 2011, 12:27
  3. Replies: 2
    Last Post: 11th February 2011, 17:53
  4. qsqltablemodel "order by" clause in setfilter?
    By jtdavidson in forum Newbie
    Replies: 5
    Last Post: 10th August 2010, 01:58
  5. Replies: 12
    Last Post: 14th June 2006, 09:24

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.