Qt Forum

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

    Update: Forum Guidelines & Code of Conduct

    Patch Oracle OCI Driver to support REF CURSOR submitted

    General and Desktop
    3
    5
    4296
    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.
    • T
      TioRoy last edited by SGaist

      I wrote a patch ("submitted to jira":https://bugreports.qt.io/browse/QTBUG-166) to Oracle OCI driver to support REF CURSOR.

      The example code:

      #include <QtCore/QCoreApplication>
      #include <QtSql/QSqlDatabase>
      #include <QtSql/QOCIDriver>
      #include <QtSql/QSqlQuery>
      #include <QtCore>
      
      Q_DECLARE_METATYPE(QOCIResult *) //Required to bind QOCIResult (QVariant)
      
      int main(int argc, char *argv[])
      {
          QCoreApplication a(argc, argv);
      
      
          QSqlDatabase db = QSqlDatabase::addDatabase("QOCI");
          db.setHostName("192.168.0.1");
          db.setUserName("user");
          db.setPassword("pass");
          db.setDatabaseName("ORACLE");
          db.open();
      
          QOCIResult *cursor = (QOCIResult *) db.driver()->createResult();
      
          QSqlQuery query;
          query.prepare("call tst.Search(:c, :busca, :tipo, :bolsa)");
          query.addBindValue(qVariantFromValue(cursor), QSql::Out);
          query.addBindValue("DI", QSql::In);
          query.addBindValue("F", QSql::In);
          query.addBindValue("T", QSql::In);
      
          if (query.exec&#40;&#41;) {
              if (cursor->exec&#40;&#41;) { //To load column information
                  QSqlQuery queryCursor(cursor);
      
                  while (queryCursor.next()) {
                      qDebug() << "Value[0]=" << queryCursor.value(0).toString();
                  }
      
              }
          }
      }
      

      [edit: Update patch link and code tags SGaist]

      1 Reply Last reply Reply Quote 0
      • H
        hsn_salhi last edited by

        Hello,
        can you please help solving some problems while using your patch ? Here is what i've done.

        • I downloaded the patch files (diff_qsql_oci.cpp.patch & diff_qsql_oci.h.patch) and applied the modifications.
        • I rebluit the oci driver by using the modifications.
        • I put the new qsql_oci cpp and h files everywhere.
        • When compiling, I have the folowing compile errors :
          @qt_metatype_id' is not a member of 'QMetaTypeId<QOCIResult*>@

        So I don't know what I missed !
        Plz I need this patch to work can you help me ?
        thank you.

        1 Reply Last reply Reply Quote 0
        • H
          hsn_salhi last edited by

          sory about that !!!!
          I know now what I missed !
          simply the first ligne in your code hihi
          @Q_DECLARE_METATYPE(QOCIResult *) //Required to bind QOCIResult (QVariant)@
          thank you for the post and the patch.

          1 Reply Last reply Reply Quote 0
          • C
            cki61 last edited by

            Hello TioRoy,

            I'm just trying to port this patch to Qt 5.4. As a newbee to Qt not just the easiest beginning, but I need access to Oracle Ref Corsors.
            I have to admit that I don't know exactly the structure of the changed classes.
            Thats I guess the reason why I can't pass the error

            • 'QOCIResult' was not declared in this scope
              of your example above.
              Question:
            • does there already exists a patch for Qt5.4?
            • I need someone knowing the corsor theme who can take a look to my/your ported patch. Would you do this?

            I'd like to give people acces to my created patch files, but can't find a possibility to upload. Do you know how to do it?

            Sincerely,
            CKI61

                            ^
            
            1 Reply Last reply Reply Quote 0
            • C
              cki61 last edited by

              Hello TioRoy,

              I'm just trying to port this patch to Qt 5.4. As a newbee to Qt not just the easiest beginning, but I need access to Oracle Ref Corsors.
              I have to admit that I don't know exactly the structure of the changed classes.
              Thats I guess the reason why I can't pass the error

              • 'QOCIResult' was not declared in this scope
                of your example above.
                Question:
              • does there already exists a patch for Qt5.4?
              • I need someone knowing the corsor theme who can take a look to my/your ported patch. Would you do this?

              I'd like to give people acces to my created patch files, but can't find a possibility to upload. Do you know how to do it?

              Sincerely,
              CKI61

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