Applies to: an ABC Report template on C5b with ISQL Anywhere, posted in the Clarion 5.5 EE group.
Problem
A report reads every record of file BILLHEAD under a filter. After the first read the report sets BILLHEAD{PROP:SQL} = 'SELECT * FROM BILLHEAD JOIN INNHEAD ON billhead.CustNumber = innhead.CustNumber ...'. BILLHEAD has 14 fields, but in the debugger, right after the NEXT, only 4 of them hold the correct data.
Solution
SELECT *returns the columns in the order the database table has them, and the file driver fills the record buffer in the order of the dictionary. If the dictionary lists the fields in a different order from the table, the values land in the wrong fields. In the thread the layouts differed from the fifth field on.- Make the two orders match. The original poster moved the fields in the dictionary to match the SQL table and recompiled; a table whose fields were once exported and re-created by a conversion program is a likely cause.
- To see which fields are wrong, CLEAR the record before the NEXT. To avoid depending on the table order, name the columns in the select instead of
*. - A join returns columns of both tables, which do not fit in the BILLHEAD record buffer. A poster advised reading the join into a generic table, for example one with 30 CSTRING(128) fields, and setting PROP:SQL on that table.
Caveats
- Re-ordering columns in the database means building a new table, copying the data, dropping the old table and renaming the new one. A poster noted that ALTER TABLE with ADD always adds the column at the end.
- The original poster's own join only filtered by customer; a poster asked whether a plain WHERE would do, and the poster said he had tried that without the join.
- The thread does not say which Clarion version of the driver was used beyond C5b.
Today (2026)
The record-order rule for SELECT * is a property of how the buffer is filled, so it likely still holds. Not re-tested on a current build.
Sources: Robert P. (Jan 2003, the question), Tim F., Pierre T., John C., Michael G. (Jan 2003) in softvelocity.products.c55ee.