Results 1 to 9 of 9

Thread: Database stored funtions calling

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jul 2013
    Posts
    8
    Thanks
    3
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Database stored funtions calling

    Hey guys,
    Am writing a database application to interact with an Oracle database. In the Oracle database i have stored procedures and functions. Problem is i cannot retrieve data or even call functions. stored procedures work just fine. The QT documentation says that functions are not fully supported, and instead advises to see the driver documentation. the thing is,..i think functions are supported in the OCI driver. How does someone go about this?
    Below is a code fragment from one of my functions

    qint32 historyid;
    QSqlQuery query;
    query.setForwardOnly(true);
    query.prepare(" call :histid := tracdba.proj_pkg.change_project(:rojid,:ver,:reaso n)");
    query.bindValue(":rojid", versioninfo.ProjectID );
    query.bindValue(":ver",versioninfo.projectVersion );
    query.bindValue(":reason", versioninfo.Reason);

    query.bindValue(":histid",0, QSql::Out);
    if(!query.exec())
    {
    qDebug()<< "DATABASE ERROR!!"<< query.lastError().databaseText();
    return "db_Exec_Failed";
    }
    historyid = query.boundValue(":histid").toInt();

  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: Database stored funtions calling

    I have not had to deal with Oracle but I think you can just :
    Qt Code:
    1. qint32 historyid;
    2. QSqlQuery query;
    3. query.setForwardOnly(true);
    4. query.prepare(" SELECT tracdba.proj_pkg.change_project(:rojid,:ver,:reaso n)");
    5. query.bindValue(":rojid", versioninfo.ProjectID );
    6. query.bindValue(":ver",versioninfo.projectVersion );
    7. query.bindValue(":reason", versioninfo.Reason);
    8.  
    9. if(!query.exec())
    10. {
    11. qDebug()<< "DATABASE ERROR!!"<< query.lastError().databaseText();
    12. return "db_Exec_Failed";
    13. }
    14. if( !query.next() )
    15. return "some_error_code";
    16.  
    17. historyid = query.record().value(0).toInt();
    To copy to clipboard, switch view to plain text mode 

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

    gbaguma (11th July 2013)

Similar Threads

  1. Calling Stored Procedure using ODBC
    By luiz.carlos.do.lago in forum Newbie
    Replies: 0
    Last Post: 20th November 2010, 23:35
  2. Problem calling stored procedure.. Help!
    By triperzonak in forum Qt Programming
    Replies: 4
    Last Post: 15th March 2010, 08:34
  3. Problem with calling stored procedures in QT
    By sudheer168 in forum Qt Programming
    Replies: 3
    Last Post: 9th November 2009, 09:07
  4. Replies: 14
    Last Post: 16th January 2009, 08:11
  5. Frozen? ... no ... calling 01800 Database
    By chaosgeorge in forum Qt Programming
    Replies: 2
    Last Post: 26th November 2006, 13:06

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.