If the user wishes to sort on any one of the five fields of a table in either ascending or descending order then how could this be coded in cobol-DB2 using minimum number of queries. We would get the column name and ascending/descending flag from front end and this functionality needs to be incorporated in a stored procedure.
Field1 Field2 Field3 Field4 Field5
abc 123 abc aaa 111
bcd 234 zxc bbb 222
If the user clicks on any field name on the front end screen for the first time the data would be displayed in ascesnding order. When he clicks on the same field name for the second time then the data would be displayed in descending order.
Would dynamic SQL be a solution? Can dynamic SQL be used in cobol? If yes , how can we use it for our application.