I have an interesting issue with the below SELECT.
Its about ORDER BY clause; I am
If you want to do that, you will have to do dynamic SQL with PL/SQL.
DECLARE
sql_str VARCHAR2(500);
sortby VARCHAR2(30) := 'your_column_name';
BEGIN
-- Dynamic PL/SQL block invokes subprogram:
sql_str := 'select * from your_table where a = 1 order by :a';
OPEN CURSOR v_your_cursor for sql_str USING sortby;
-- Then iterate your cursor.
END;
/