How to apply Oracle query Hint?
-
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
-
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.
-
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.