sort data in no DB block [message #319846] |
Tue, 13 May 2008 03:32 ![Go to next message Go to next message](/forum/theme/orafaq/images/down.png) |
bodoid
Messages: 7 Registered: January 2007
|
Junior Member |
|
|
Hi all,
can anyone tell me, if it is possible to sort records in non db block in any simple way? I dont want to loop through records and sort them.
thank you all
Pavel
|
|
|
|
Re: sort data in no DB block [message #319867 is a reply to message #319850] |
Tue, 13 May 2008 04:57 ![Go to previous message Go to previous message](/forum/theme/orafaq/images/up.png) ![Go to next message Go to next message](/forum/theme/orafaq/images/down.png) |
bodoid
Messages: 7 Registered: January 2007
|
Junior Member |
|
|
yes i do it in loop cursor, but i search a lot of values from another tables, so it is impossible to have "order by" in statement of cursor i think. All values i have after fulling the grid (block).
I hope you understand me
thank you
|
|
|
Re: sort data in no DB block [message #319880 is a reply to message #319867] |
Tue, 13 May 2008 05:53 ![Go to previous message Go to previous message](/forum/theme/orafaq/images/up.png) ![Go to next message Go to next message](/forum/theme/orafaq/images/down.png) |
![](/forum/images/custom_avatars/72104.gif) |
Littlefoot
Messages: 21823 Registered: June 2005 Location: Croatia, Europe
|
Senior Member Account Moderator |
|
|
Quote: | it is impossible to have "order by" in statement of cursor
|
Wrong! What makes you think so?
SQL> declare
2 cursor cur_e is --> this is a cursor declaration
3 select e.ename, e.job, d.dname, e.sal, b.comm
4 from emp e, dept d, bonus b
5 where e.deptno = d.deptno
6 and b.ename (+) = e.ename
7 order by d.dname, e.ename, b.comm; --> this is the ORDER BY clause
8 cur_r cur_e%rowtype;
9 l_sum_sal number := 0;
10 begin
11 open cur_e;
12 loop
13 fetch cur_e into cur_r;
14 exit when cur_e%notfound;
15
16 l_sum_sal := l_sum_sal + cur_r.sal;
17 end loop;
18 close cur_e;
19 dbms_output.put_line('All of them earn ' || to_char(l_sum_sal, '$999G990D00'));
20 end;
21 /
All of them earn $40,225.00
PL/SQL procedure successfully completed.
SQL>
I used such an example on purpose, just to emphasize the way cursor is explicitly declared (but I had to open it, fetch, take care about exiting the loop, close it); normally, I'd use cursor FOR loop which would eliminate most of these steps.
|
|
|
|
|
|
Re: sort data in no DB block [message #320235 is a reply to message #320049] |
Wed, 14 May 2008 07:03 ![Go to previous message Go to previous message](/forum/theme/orafaq/images/up.png) |
bodoid
Messages: 7 Registered: January 2007
|
Junior Member |
|
|
djmartin wrote on Tue, 13 May 2008 19:58 | bodoid wrote on Tue, 13 May 2008 18:32 | I dont want to loop through records and sort them.
|
Why? It will only take moments and there are no fees associated with sorting.
David
|
i ment, i don't want use any sort algoritmus like shake, bubble sort etc.
never mind ... i think it is impossible to sort records in simple way.
|
|
|