Re: Order By in 4GL Report
Posted in 1997
}From: batonnet@zeta.org.au (Bryan Tonnet) }Date: 7 Jan 1997 18:26:17 +1100 }X-Informix-List-Id: <news.32288> } }Anyone know of a decent (decent = not recopying the entire report block) way }to include a dynamic "order by" in a 4GL report? } }That is, if my report driver is; } } LET sql_stmt_l = "SELECT a,b,c FROM z" } } IF something THEN } LET sql_stmt_l = sql_stmt_l clipped, " ORDER BY a" } ELSE } LET sql_stmt_l = sql_stmt_l clipped, " ORDER BY b" } END IF } }; can the report be told of a variable "order by", or am I stuck with }a different report block for each possibility? You are stuck with a different report for each ORDER BY that you need. If you ever get to look at the generated C code, then after you've recovered from the heart-attack, you'll begin to see why dynamic ORDER BY operations would be rather hard to support. The whole of a report is a complex state machine implemented with 'computed gotos' (Fortran-speak, but implemented in C), and the sequence in which the various parts of a report (page header, before group, after group, on every row, etc) are triggered depends on the ORDER BY clause, and so to handle multiple order by sequences, you'd have to have (at a minimum) different tables of jumps for the different order by clauses. I'd hate to have to prototype it, even for a simple one-pass report with only one level of order by and no aggregates or group aggregates, let alone try to handle all possible cases. Yours, Jonathan Leffler (johnl@informix.com) #include <disclaimer.h>