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
What is primary key in db?
write an sql query to find names of employee start with 'a'? : Sql dba
what are ddl statements in mysql? : Sql dba
What are schema-level triggers?
What is pl sql in oracle?
What are different joins used in sql?
What is pl sql code?
Is nosql faster than sql?
Show the two pl/sql cursor exceptions.
what is myisam? : Sql dba
Why does sql need a server?
What can you do with pl sql?
Which are the different types of indexes in sql?
what is a database lock ? : Sql dba
What are crud methods?