Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Order by Rownum Not Working

Christine1111Apr 20 2010 — edited Apr 20 2010
Hello -

I have an insert in a package that basically does an "Insert Into <Table> Select.....".

The problem I'm having is that, as part of the result set, I'm doing a
case when rownum > 1 then chr(13)||'----------------------------------------------------------------------------------------------------------------------------'
||chr(10)  else null end
I included this in order to give myself a separator between rows returned. This works fine but then at the end of the select statement I tell it to ORDER BY rownum. For some reason when the insert is made to the table it is not ordering by rownum correctly.

I have done this in several other procedures and it works fine. This one even works fine in our development environment but in test it will not order correctly. I have to do it this way because one of the procedures that is called (after the insert is made) simply selects the results that were inserted and dumps them into an email, and I cannot change this procedure.

Does anyone have any idea why this would not be working? When I run just the select part separately (outside of the pacakge) it orders correctly.

Any help would be greatly appreciated.

Thanks,
Christine
This post has been answered by ajallen on Apr 20 2010
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 18 2010
Added on Apr 20 2010
11 comments
2,763 views