In my listing report with PRD, I am looking to add a parameter ${p_order_on} with two options: ASC or DESC, i.e. (in MySQL)
===
SELECT ....
....
FROM mydb.mytable
ORDER BY ${p_order_by} ${p_order_on}
===
Where I can use an integer to set up the parameter ${p_order_by} which corresponding to the column number, so I can sort by any columns without problem. But ${p_order_on} is either 'ASC' or 'DESC' which will be interpolated as a string in the SQL and yield SQL error, i.e. the following
ORDER BY 2 "DESC" ---> this should be ORDER BY 2 DESC (without the quotation marks around DESC)
I tried setting up 'Value Type' of the parameter ${p_order_on} to either 'String' or 'Object'. neither is working. Adding the ${p_order_on} in Query Scripting is also not working (from my understanding, the query script can only change the text in design-time, not run-time). the parameter in SQL sounds to be a placeholder and always quoted by Pentaho. Is there a good way that I can remove the quotation marks around 'DESC' at run-time. so that I can control the sorting by ascending or descending orders.
Many thanks in advance,
===
SELECT ....
....
FROM mydb.mytable
ORDER BY ${p_order_by} ${p_order_on}
===
Where I can use an integer to set up the parameter ${p_order_by} which corresponding to the column number, so I can sort by any columns without problem. But ${p_order_on} is either 'ASC' or 'DESC' which will be interpolated as a string in the SQL and yield SQL error, i.e. the following
ORDER BY 2 "DESC" ---> this should be ORDER BY 2 DESC (without the quotation marks around DESC)
I tried setting up 'Value Type' of the parameter ${p_order_on} to either 'String' or 'Object'. neither is working. Adding the ${p_order_on} in Query Scripting is also not working (from my understanding, the query script can only change the text in design-time, not run-time). the parameter in SQL sounds to be a placeholder and always quoted by Pentaho. Is there a good way that I can remove the quotation marks around 'DESC' at run-time. so that I can control the sorting by ascending or descending orders.
Many thanks in advance,