Re: Order By in 4GL Report
Posted in 1997
batonnet@zeta.org.au (Bryan Tonnet) wrote: :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? As long as the column you use for order by can be put into the same program variable you can easily solve your problem. If the columns you order by are of different types they can often be put into character variables, but some formatting may be needed to sort correctly. foreach c_somecursor into l_a, l_b, l_c if something then let l_order = l_a else let l_order = l_b end if output to report r_report (l_order, l_a, l_b, l_c) end foreach finish report report r_report(p_order, p_a, p_b, p_c) define... order by p_order before group of p_order ... Nils.Myklebust@idg.no NM Data AS, P.O.Box 9090 Gronland, N-0133 Oslo, Norway My opinions are those of my company The Informix FAQ is at http://www.iiug.org