At first I want to apologise for my approximate English. I’m doing an internship in which I have to improve non regression test. I work on a Sybase IQ database with tables with no primary keys, so I want to use unique indexes to order my select. My selects must be sorted the same way for comparison, and today what is done is an order by 1,2,3,4,5,…,max column num. So I want to slim the queries by using only unique indexed column. I have made this query :
SELECT * FROM MyTableName
ORDER BY (SELECT list(column_name) FROM sp_iqindex_alt('MyTableName') WHERE unique_index = "Y")
The query complete but the order by doesn’t work. Is there anyone who knows how to make such a query ? Thanks a lot in advance
You need to dynamically construct the order-by clause with the desired column names, and then execute the resulting SQL query with execute-immediate.