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)