Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Database function support in QT
Forum Updated to NodeBB v4.3 + New Features

Database function support in QT

Scheduled Pinned Locked Moved General and Desktop
16 Posts 3 Posters 4.8k Views 1 Watching
  • 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.
  • G Offline
    G Offline
    gbaguma
    wrote on last edited by
    #1

    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.

    1 Reply Last reply
    0
    • G Offline
      G Offline
      gbaguma
      wrote on last edited by
      #2

      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

      1 Reply Last reply
      0
      • G Offline
        G Offline
        gbaguma
        wrote on last edited by
        #3

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

        1 Reply Last reply
        0
        • S Offline
          S Offline
          SergioDanielG
          wrote on last edited by
          #4

          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.

          www.ftatv.com.ar El foro argentino de la TV libre

          1 Reply Last reply
          0
          • G Offline
            G Offline
            gbaguma
            wrote on last edited by
            #5

            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

            1 Reply Last reply
            0
            • G Offline
              G Offline
              gbaguma
              wrote on last edited by
              #6

              @
              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();@

              1 Reply Last reply
              0
              • S Offline
                S Offline
                SergioDanielG
                wrote on last edited by
                #7

                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.

                www.ftatv.com.ar El foro argentino de la TV libre

                1 Reply Last reply
                0
                • G Offline
                  G Offline
                  gbaguma
                  wrote on last edited by
                  #8

                  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

                  1 Reply Last reply
                  0
                  • G Offline
                    G Offline
                    gbaguma
                    wrote on last edited by
                    #9

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

                    Thanks very much

                    1 Reply Last reply
                    0
                    • G Offline
                      G Offline
                      gbaguma
                      wrote on last edited by
                      #10

                      Really guys not a single soul out there???

                      1 Reply Last reply
                      0
                      • B Offline
                        B Offline
                        bobhairgrove
                        wrote on last edited by
                        #11

                        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.

                        1 Reply Last reply
                        0
                        • B Offline
                          B Offline
                          bobhairgrove
                          wrote on last edited by
                          #12

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

                          1 Reply Last reply
                          0
                          • G Offline
                            G Offline
                            gbaguma
                            wrote on last edited by
                            #13

                            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

                            1 Reply Last reply
                            0
                            • B Offline
                              B Offline
                              bobhairgrove
                              wrote on last edited by
                              #14

                              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.

                              1 Reply Last reply
                              0
                              • G Offline
                                G Offline
                                gbaguma
                                wrote on last edited by
                                #15

                                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

                                1 Reply Last reply
                                0
                                • G Offline
                                  G Offline
                                  gbaguma
                                  wrote on last edited by
                                  #16

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

                                  1 Reply Last reply
                                  0

                                  • Login

                                  • Login or register to search.
                                  • First post
                                    Last post
                                  0
                                  • Categories
                                  • Recent
                                  • Tags
                                  • Popular
                                  • Users
                                  • Groups
                                  • Search
                                  • Get Qt Extensions
                                  • Unsolved