Oracle OCI Result cannot bind to return a SYS_REFCURSOR



  • Hello, I recently built Qt statically and it came out pretty well. One of the issues I have been working around is how to return a SYS_REFCURSOR object from Oracle base to a QSqlResult or something similar. I found a patch https://bugreports.qt.io/browse/QTBUG-166

    I have tried the exact same thing, but somehow, it managed to print out:

    ORA-01008: not all variables bound
    Unable to execute statement.

    Here is my code:

    Q_DECLARE_METATYPE(QOCIResult *)

    QOCIResult *p_cursor = reinterpret_cast<QOCIResult*>(db.driver()->createResult());

    QSqlQuery content_query(db);
    content_query.prepare("begin ispovedi.get_ord_kategorii_list(:p_cursor); end;");
    content_query.addBindValue(qVariantFromValue(p_cursor), QSql::Out);

    if (content_query.exec())
    {
    p_cursor->exec();
    }
    else
    {
    qCritical("%s.", qPrintable(content_query.lastError().text()));
    }

    I have a crystal clear connection to database and I can execute other statements, as well, not a problem. The only problem is how to return a SYS_REFCURSOR.

    Thank you.