order by in pl/sql [message #372037] |
Fri, 05 January 2001 08:46 |
Krishnamurthy
Messages: 2 Registered: January 2001
|
Junior Member |
|
|
Dear all,
How insert fields in another table using a select
statement in records are ordered in a Pl/sql Procedure.
Example:
create or replace procedure x as
begin
insert into nsd1 SELECT * FROM (SELECT * from nsd order by rno) where rownum=1;
end;
I am Getting error at order by,Please help me..
Thank,
Murthy.
|
|
|
Re: order by in pl/sql [message #372039 is a reply to message #372037] |
Fri, 05 January 2001 09:59 |
Jayant
Messages: 8 Registered: January 2001
|
Junior Member |
|
|
just do this change in insert statement :-
insert into nsd1 SELECT * FROM (SELECT * from nsd where rownum = 1 order by
rno );
I hope this will help u.....
Jayant
|
|
|
Re: order by in pl/sql [message #372040 is a reply to message #372037] |
Fri, 05 January 2001 10:09 |
Sathian Devarajan
Messages: 4 Registered: September 1999
|
Junior Member |
|
|
Hi Murthy,
As you cannot use an order by in the subquery, Create an index on the column use want to order by and use a hint in the subquery and force it with a where clause to use the index. I hope that would solve your problem.
I tried with the example down below
select * from (select /*+ index (emp emp_sal ) */ * from emp where sal > 0 )
where rownum = 1
Sathian
|
|
|