Patch Oracle OCI Driver to support REF CURSOR submitted



  • 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]



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



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



  • 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

                    ^


  • 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

                    ^

Log in to reply