take one table is t1 and in that column name is f1
f1 column values are
200
5000
3000
7000
300
600
100
400
800
400
i want display the values asc and desc in a single output.
sample output is
f1.a
100
200
300
400
500
600
etc......
and f1.d is
5000
4000
3000
2000
1000
etc...

Answer Posted / suresh

declare
type xyz is ref cursor return t1%rowtype;
c1 xyz;
e t1%rowtype;
begin
open c1 for select f1 from t1 order by f1 asc;
dbms_output.put_line('ascending order result');
dbms_output.put_line('---------------------');
loop
fetch c1 into e;
exit when c1%notfound;
dbms_output.put_line(e.f1);
end loop;
dbms_output.put_line('---------------------');
dbms_output.put_line('descending order result');
dbms_output.put_line('---------------------');
close c1;
open c1 for select f1 from t1 order by f1 desc;
loop
fetch c1 into e;
exit when c1%notfound;
dbms_output.put_line(e.f1);
end loop;
close c1;
end;

Is This Answer Correct ?    5 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is primary key in db?

517


write an sql query to find names of employee start with 'a'? : Sql dba

575


what are ddl statements in mysql? : Sql dba

577


What are schema-level triggers?

574


What is pl sql in oracle?

579






What are different joins used in sql?

548


What is pl sql code?

585


Is nosql faster than sql?

540


Show the two pl/sql cursor exceptions.

612


what is myisam? : Sql dba

577


Why does sql need a server?

561


What can you do with pl sql?

556


Which are the different types of indexes in sql?

558


what is a database lock ? : Sql dba

589


What are crud methods?

549