[archive] SQL 'Order By' problem
[Migrated content. Thread originally posted on 30 July 2009]Hello
We have the following code embedded in a cobol program.
We want the returned records to be returned sorted in either ascending or descending order depending on the variable ws-sort-flag.
We get the following error message when we run it:
"a constant expression was encountered in the Order By list, position 1"
When we run the identical code in the SQL Managemant Console it works fine.
Does anyone have any ideas or different code that might work?
DECLARE ConvCode1 CURSOR FOR
SELECT CST_RectCode, CST_RectFmma, CST_RectName,
FROM tbl_Customer WITH (NOLOCK)
WHERE CST_IDNUMBER = :WS-Handler-IDNumber
WHEN 0 THEN
WHEN 1 THEN
FOR READ ONLY