Database function support in QT

  • Am wondering whether there is support at all for calling stored functions in an oracle database. I mean the OCI driver provides this support but do the QT classes support it.

  • the documentation just says not fully supported and only refers to the associated OCI driver. But as far as i know the oracle driver seems to have full support of functions

    so does any one know hw someone could possibly go abt this,..or i have to redefine the functions and instead use procedures with out parameters iin the database itself

  • And btw,..i have seen a large amount of people that have constantly had this problem ,...since 2006, am actually wondering whether has something to say,...these threads have all been going unanswered for some reason

  • Hi gbaguma.
    I don't use oracle but, maybe you can try using
    "Oracle ODBC Driver":
    Hope it's util.

  • Hey SergioDanielG,

    Thank you for your reply. But even if i were to use Oracle ODBC,..what would be the syntax for this. As far as i know,..ODBC will support these functions but will discard the returned value,..kindly correct me if am wrong. i have sample code below

  • @
    qint32 historyid;
    QSqlQuery query;
    query.prepare(" call :histid := tracdba.proj_pkg.change_project(:projid,:ver,:reason)");
    query.bindValue(":projid", versioninfo.ProjectID ); //faulty
    query.bindValue(":ver",versioninfo.projectVersion );
    query.bindValue(":reason", versioninfo.Reason);
    query.bindValue(":histid",0, QSql::Out);
    { qDebug()<< "DATABASE ERROR!!"<< query.lastError().databaseText();
    return "db_Exec_Failed";
    historyid = query.boundValue(":histid").toInt();@

  • Based on "QSqlDatabase doc": and "odbc connection string":
    db = QSqlDatabase::addDatabase("QODBC");
    db.setDatabaseName("Include "Driver={Microsoft ODBC for Oracle}");
    if ( {
    // success!

    Hope it's util.

  • Yes Sergio,..the thing is i dont have problems with database connectivity or even reading information from the database or even calling stored procedures. The problem is just functions,...these for which QT says that are not fully supported,...otherwise i can connect, info,..and even call stored procedures,...but i can not call functions. The code fragment above is just what i thought would be right for calling a function in a remote oracle db ,..but sadly it does not work

  • so am just wondering if there is a work around on this

    Thanks very much

  • Really guys not a single soul out there???

  • Use a query like this: "SELECT your_func(:arg1, :arg2) AS retval" and fetch the return value as you would in a regular SELECT query. At least that is how I do it in MySQL.

  • Or maybe you have to use the dummy table "dual" in Oracle:
    "SELECT your_func(...) AS retval FROM dual;"

  • I have actually tried to do that,..the problem is am trying to do some updates in the function, so oracle replies that DML statements are not allowed in select statements

  • It looks to me like you will have to wrap your function calls in another Oracle stored procedure and call that instead of the function. This is a restriction on the database side, not in Qt.

  • hey bobhairgrove, unfortunately for me i cant modify the database functions or stored procedures, policy, i have to actually use this function to get the data i need. but isnt there anyway for sure to handle this in QT,..just to call an oracle function even if the data returned is discarded

  • So guys,..if anyone knows a way to do this out there, me out

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.