Prepared TMyQuery triggers Assertion Failure in MyClasses line 6287
Posted: Sat 10 Mar 2018 21:24
I'm working with DevArt's MyDAC for RAD Studio 10.2, version 9.1.4, using Delphi XE10.2 VCL. I have a TMyQuery component that, when Prepared before execution, triggers an Assertion Failure in MyClasses.pas at line 6287 on activation. Tracing further, I find the error is triggered during processing of line 12659 of the Data.DB unit -- the OpenCursor statement in the TDataSet.SetActive method. Code for the TMyQuery SQL follows below. The Integer parameters :Rows and :Columns have been set to 2 and 1000 respectively when I've been testing it.
Workaround: simply removing the Prepare call for this query eliminates the problem. I'd love to get an understand of why it's happening, however. (I notice from the documentation that Prepare can be "unstable".... Perhaps the specifics of the problem I'm encountering will help make it stabler -- or perhaps not.) An apparently identical TMyQuery component functions without difficulty on another form in my application, including when it is Prepared before activation.
Workaround: simply removing the Prepare call for this query eliminates the problem. I'd love to get an understand of why it's happening, however. (I notice from the documentation that Prepare can be "unstable".... Perhaps the specifics of the problem I'm encountering will help make it stabler -- or perhaps not.) An apparently identical TMyQuery component functions without difficulty on another form in my application, including when it is Prepared before activation.
Code: Select all
SELECT CellNbr, CAST(:Rows AS Integer) AS `Rows`,
CAST(:Columns AS Integer) AS `Columns`,
((CellNbr - 1) / :Columns) + 1 AS RowNbr,
CAST(MOD((CellNbr - 1), :Columns) + 1 AS Integer) AS ColumnNbr,
MOD((CellNbr - 1), :Columns) * :Rows + ((CellNbr - 1) / :Columns) + 1 AS CellNbrByCol
FROM CellNbr
WHERE CellNbr <= (:Rows * :Columns)