0

I was just wondering if it is possible to retrieve data from a table using a cursor and then print that data in an ascending order. In my code so far I have managed to retrieve the data with a cursor and print it but is there a way to print data in ascending order?

VeryNew
  • 5
  • 2

1 Answers1

0

A cursor can be thought of as a specification for a set of rows. The results will be ordered according to any order by clause, or if there isn't one, they will be returned as they are retrieved, which will be subject to how they are physically stored and the execution plan chosen.

If you need to reorder the results returned from the database, you will need to do that in the calling client after fetching all the rows.

(Not related to the question, but I strongly advise against using char for anything. Also, you don't need sqlcode because sqlerrm already contains it.)

William Robertson
  • 15,273
  • 4
  • 38
  • 44