You have given Order by 1. I am asking how to pass the "1" and the format desc or asc dynamically before the open cursor statement. Order by 1 is hard coded. My requirement is to have a single cursor and the column no and format is to be changed as per the requirement from java team. Java team is calling that SP. They will give me the format(desc or asc) and column no. So I have to move that before open cursor statement.