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. How to apply Oracle query Hint?
Forum Updated to NodeBB v4.3 + New Features

How to apply Oracle query Hint?

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 2.0k 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.
  • S Offline
    S Offline
    skeom21
    wrote on last edited by
    #1

    Hi..

    There is a ascending default index on column "wimindex".
    I want to retrieve jsust recent one using oracle hint like below.
    But it seems that Oracle query hint doesn't work.
    Of course this query is working well on Oracle sql/plus.
    Just -QT- Qt QSqlQuery doesn't work.
    Would you help me ? or any hint?

    Below is my code.
    thanks...
    @
    QString lastWimIdxQuery = "SELECT /*+ index_rs_desc(VIOLATE, VIOLATE(wimindex)) */
    WIMINDEX FROM VIOLATE WHERE wimindex > 0 and rownum =1";

    query.exec(lastWimIdxQuery);

      int fieldNo = query.record().indexOf("WIMINDEX");
    

    if(query.next())
    {

    this->m_lastWimIdx = query.value(fieldNo).toInt();
    qDebug()<<this->m_thread_name << " : " << this->m_lastWimIdx;
    }else
    {
    return;
    }
    @

    Edit: please use @ tags around code sections to make them readable; Andre

    1 Reply Last reply
    0
    • F Offline
      F Offline
      fluca1978
      wrote on last edited by
      #2

      Strange, the driver has an implementation of prepare that uses the native query syntax, so I think Oracle should be able to parse its own query:

      @r = OCIStmtPrepare(d->sql,
      d->err,
      txt,
      len,
      OCI_NTV_SYNTAX,
      OCI_DEFAULT); @

      Can you log the actual query statement to see what is going on and what is parsed? What is the query returned by the query object itself? How can you tell the query is not working?

      Beside, query hints are the worst invention I had ever seen in a database and reflect the pure commercial spirit behind Oracle. I strongly suggest to avoid using hints.

      1 Reply Last reply
      0
      • S Offline
        S Offline
        skeom21
        wrote on last edited by
        #3

        well..
        I don't see OCIStmtPrepare function in QT. (I'm using ODBC3)

        Anyway, ther executedQuery() returned exactly same query what I input.

        And.. the retun value is the first thing of default asceding index.
        This is how I tell the hint does not work as I intened.

        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