ORDER EXTERNAL BY
Posted in 1995
I am having a bizarre problem using ORDER EXTERNAL BY in a report. For some reason in this program the system is ignoring the EXTERNAL part and re-ording all the rows in my report. I even checked with SET EXPLAIN ON and I can see the report re-selecting the rows from a temp table and performing the order by. Has anyone ever come across this before? Below is an excerpt of the code. In this particular example the rows come out in ASCENDING order (what is says in the external) not DESCENDING that is in the select statement. There are actually several possible order bys for the select statement that are user selected. But they all come out exactly like the ORDER EXTERNAL BY in the report. PLATFORM - 4GL 4.11.UC2 and ONLINE 5.01.UD3 running on Solaris. Jason Harris RSWA: CODE: ... DEFINE p_temp RECORD arca_custid LIKE ar_custactivity.arca_custid, arcu_name LIKE ar_customer.arcu_name, arcu_gripcode1 LIKE ar_customer.arcu_gripcode1, arcu_gripcode2 LIKE ar_customer.arcu_gripcode2, p_total LIKE ar_custactivity.arca_amount END RECORD, ... LET p_query = " SELECT arca_custid, arcu_name, ", " arcu_gripcode1, arcu_gripcode2, " SUM(arca_amount)", " FROM ar_custactivity, ar_customer", " WHERE arca_custid = arcu_custid ", " GROUP BY 1,2,3,4", " ORDER BY 4 DESC" PREPARE p_1 FROM p_query DECLARE c_report CURSOR FOR p_1 START REPORT sa_rcustP FOREACH c_report INTO p_temp.* OUTPUT TO REPORT sa_rcustP(p_temp.*) END FOREACH FINISH REPORT sa_rcustP ... REPORT sa_rcustP(p_temp) DEFINE p_temp RECORD arca_custid LIKE ar_custactivity.arca_custid, arcu_name LIKE ar_customer.arcu_name, arcu_gripcode1 LIKE ar_customer.arcu_gripcode1, arcu_gripcode2 LIKE ar_customer.arcu_gripcode2, p_total LIKE ar_custactivity.arca_amount END RECORD, ... OUTPUT REPORT TO PRINTER { ignored due to "START REPORT" code above } LEFT MARGIN 0 { default = 5 } RIGHT MARGIN 132 { default = 132 only used with "EVERY ROW" } TOP MARGIN 2 { default = 3 } BOTTOM MARGIN 2 { default = 3 } PAGE LENGTH 66 { default = 66 } ORDER EXTERNAL BY p_temp.p_total, p_temp.arcu_gripcode1, p_temp.arcu_gripcode2 FORMAT ...