Database function support in QT
-
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
-
Hi gbaguma.
I don't use oracle but, maybe you can try using
"Oracle ODBC Driver":http://www.oracle.com/technetwork/database/windows/index-098976.html
Hope it's util.
Regards. -
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.setForwardOnly(true);
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);
if(!query.exec())
{ qDebug()<< "DATABASE ERROR!!"<< query.lastError().databaseText();
return "db_Exec_Failed";
}
historyid = query.boundValue(":histid").toInt();@ -
Based on "QSqlDatabase doc":http://qt-project.org/doc/qt-5.0/qtsql/qsqldatabase.html#setDatabaseName and "odbc connection string":http://www.connectionstrings.com/providers/microsoft-odbc-for-oracle
@...
db = QSqlDatabase::addDatabase("QODBC");
db.setDatabaseName("Include "Driver={Microsoft ODBC for Oracle}");
db.setHostName("serverHost");
db.setDatabaseName("yourDB");
db.setUserName("yourUser");
db.setPassword("yourPassword");
if (db.open()) {
// success!
}
...@Hope it's util.
Regards. -
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,...read 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
-
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;" -
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,...company policy,...so 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