Results 1 to 3 of 3

Thread: QOCI..query selection...

  1. #1
    Join Date
    Jan 2012
    Location
    Argentina
    Posts
    167
    Thanks
    33
    Thanked 10 Times in 10 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default QOCI..query selection...

    //----------------------SOLVED
    OK so I was just trying different things and deleting the ";" at the end of the line solves it *-*. Maybe it can help other people
    //---------------------END SOLVED



    Hi guys im having a real problem with the OCI driver

    i execute this line
    SELECT rn, frase, autor FROM (SELECT rownum AS rn, t.frase, t.autor FROM TABLE_frases t) where rn =4;
    in the SQL Developer with no problems, I receive the line I want.

    but when I do this in my app

    Qt Code:
    1. if (db.open ()){
    2. query = new QSqlQuery (db);
    3. query->exec ("SELECT COUNT (*) FROM TABLE_FRASES");
    4. query->next ();
    5. int random_row = this->random_number (query->value (0).toInt ());
    6. query->exec ("SELECT rn, frase, autor FROM (SELECT rownum AS rn, t.frase, t.autor FROM TABLE_FRASES t) WHERE rn = 4;");//+ random_row);
    7. query->next ();
    8. QStringList frase_autor;
    9. qDebug () << query->value (0).toString ()<< query->value (1).toString ();
    To copy to clipboard, switch view to plain text mode 

    executing the same line gives the following result:

    QSqlQuery::value: not positioned on a valid record
    QSqlQuery::value: not positioned on a valid record
    "" ""
    Anyone knows what the problem might be?
    Last edited by KillGabio; 11th February 2012 at 06:14.

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: QOCI..query selection...

    QSqlQuery::exec() returns a bool indicating success: you should check that. When it is false you should look at QSqlQuery::lastError() for information on the problem.

  3. The following user says thank you to ChrisW67 for this useful post:

    KillGabio (11th February 2012)

  4. #3
    Join Date
    Jan 2012
    Location
    Argentina
    Posts
    167
    Thanks
    33
    Thanked 10 Times in 10 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QOCI..query selection...

    yes sorry i did that, as the debugging part is not going to be part of the app I started deleting the lines involving printf, qDebug , cout, etc...

    the inverted commas quoted are the result of lastError().text () information..

    thanks chris!

Similar Threads

  1. Qoci
    By hashimov in forum Qt Programming
    Replies: 2
    Last Post: 15th December 2011, 09:56
  2. QOci with qt 4.7.3 x64
    By Harald Klingel in forum Qt Programming
    Replies: 1
    Last Post: 25th July 2011, 08:17
  3. QOCI plugin with Oracle RAC
    By davidovv in forum Qt Programming
    Replies: 4
    Last Post: 7th July 2011, 11:54
  4. Pb connexion distant oracle database using QOCI
    By mourad in forum Qt Programming
    Replies: 0
    Last Post: 16th December 2010, 10:52
  5. Replies: 1
    Last Post: 24th November 2008, 12:02

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.