I have a requirement where i need to return different data types from a decode
statement you shall have to change your requirement then - since that is not possible.
and if you sort by the string:
LAST_NAME|| ',' || RESERVE_BEGIN_DATE
that won't sort properly - think about why it wouldn't....
It seems you might be best served by using dynamic SQL here - using a different order by OR - by encoding the data in a string so that it all sorts properly.
eg:
order by decode( :x,
'LN_AD', rpad( nvl( last_name, ' ' ), 30 ) ||
nvl( to_char(reserve_begin_date, 'yyyymmddhh24miss' ), '00000000000000' ),
'AD_LN', nvl( to_char(reserve_begin_date, 'yyyymmddhh24miss' ), '00000000000000' ) ||
rpad( nvl( last_name, ' ' ), 30 ),
.....
or, you can use a bigger order by:
order by decode( :x, 'LN_AD', last_name ), decode( :x, 'LN_AD', reserve_begin_date ),
decode( :x, 'AD_LN', reserve_begin_date ), decode( :x, 'AD_LN', last_name ),
decode( :x, 'TD_LN', insert_date ), decode( :x, 'TD_LN', last_name ),
decode( :x, 'LN_TD', last_name ), decode( :x, 'LN_TD', insert_date ),
decode( :x, 'OR_ID', order_id );