Page 1 of 1

strange odac behaviour in TOraQuery -ODAC 6.90.0.54 bcb 2009

Posted: Thu 14 Jan 2010 12:24
by albourgz
I have this table:
SQLWKS> desc cec.threadToRead
Column Name Null? Type
------------------------------ -------- ----
TRIGRAM VARCHAR2(3)
UNPLANNEDTROUBLEID NUMBER(10)

I have a TOraQuery named QRThreadToRead (in datamodule FDM):
sql:
SELECT UNPLANNEDTROUBLEID, ROWID from cec.threadToRead WHERE TRIGRAM=:1
Update sql (delete): DELETE FROM CEC.THREADTOREAD
WHERE
ROWID = :Old_ROWID

If I set param as SLO:
sql>SELECT UNPLANNEDTROUBLEID, count(*) from cec.threadToRead WHERE TRIGRAM='SLO' group by UNPLANNEDTROUBLEID
having count(*)>1;
UNPLANNEDT COUNT(*)
---------- ----------
0 rows selected.


Look at this code:

Code: Select all

if (!FDM->QRThreadToRead->Prepared)
    FDM->QRThreadToRead->Prepare();
FDM->QRThreadToRead->Params->Items[0]->AsString="SLO";
FDM->QRThreadToRead->Active=true;

for (;!FDM->QRThreadToRead->Eof;FDM->QRThreadToRead->Next()) {
       FDM->QRThreadToRead->Delete();
}
In debug, loops fine 6 times without error in FDM->QRThreadToRead->Delete(); statement.
7th execution: exception on FDM->QRThreadToRead->Delete(); statement:
Project cec.exe raised exception class EAssertionFailed with message 'Assertion failure (D:\Projects\Delphi\Dac\Common\Source\MemData.pas, line 7458)'.
What's wrong?????

Posted: Wed 20 Jan 2010 09:26
by Plash
You don't need to call the Next method in your loop. When you call the Delete method, the query moves to the next record automatically.

Posted: Wed 20 Jan 2010 09:55
by albourgz
This would explain only one record on 2 to be deleted.
This doesn't explain the exception!

Posted: Wed 27 Jan 2010 09:51
by Plash
We could not reproduce the problem. Please send to support*devart*com a complete small sample that demonstrates the problem, including the script for creating database objects.