We're using C/CGI scripting against a DB2 database.
We're working on a page where if the user clicks on a column header it will toggle and sort ASC/DESC.
The problem is that we are sorting by a number of columns so that when we run the sort, each column has to have ASC or DESC following the column name because of DB2 syntax.
For example, one statement looks like this:
---------------------------------------------
SELECT t5.appr_id
FROM nysa.bp11t_approp_cuts t5,
nysa.bp86t_negotiation t6
WHERE t5.neg_code = t6.neg_code AND
t5.status = :bp11.status AND
t6.current = 'Y'
ORDER BY 2,3,4,5,6,7,8,9,10,12;
----------------------------------------------
So, the order by should be ORDER BY 2 DESC,3 DESC,4 DESC, etc.
We tried using strcat and searching for the token of a comma, and then adding the DESC or ASC on after but is there an easier way?
Thanks in Advance.
John
We're working on a page where if the user clicks on a column header it will toggle and sort ASC/DESC.
The problem is that we are sorting by a number of columns so that when we run the sort, each column has to have ASC or DESC following the column name because of DB2 syntax.
For example, one statement looks like this:
---------------------------------------------
SELECT t5.appr_id
FROM nysa.bp11t_approp_cuts t5,
nysa.bp86t_negotiation t6
WHERE t5.neg_code = t6.neg_code AND
t5.status = :bp11.status AND
t6.current = 'Y'
ORDER BY 2,3,4,5,6,7,8,9,10,12;
----------------------------------------------
So, the order by should be ORDER BY 2 DESC,3 DESC,4 DESC, etc.
We tried using strcat and searching for the token of a comma, and then adding the DESC or ASC on after but is there an easier way?
Thanks in Advance.
John