I have a table emp. There is only one column in the table.
In that , there are only three rows in that column.
The value in the first row is 'A' and the value in the
second row is 'B' and the third row is 'C'. Now, my question
is ,

How will you write a select query to display the output as
B
C
A

Note: order by cannot be used coz it gives us output as CBA.
But the output should be BCA.

Answer Posted / ajitnayak

declare
type samp_type is table of VARCHAR2(20)
index by binary_integer;

table_type samp_type;

cursor c1 is
select Colum-Name from Table_name;

begin
open c1;

fetch c1 bulk collect into table_type;

close c1;

for i in reverse 1..4 loop
dbms_output.put_line(table_type(i));
end loop;
end;

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is memory advisor in Oracle?

622


Explain an exception?

558


Explain integrity constraints?

654


 What are the oracle DML commands possible through an update strategy?

572


what is the dual table in oracle?

543






How to call a stored function in oracle?

564


Explain the use of file option in exp command.

591


How to use "if" statements on multiple conditions?

711


what's query optimization and without use of IN AND Exist can we get another way data from query

1659


How to write text literals in oracle?

600


Give the various exception types.

534


What is user managed backup in Oracle?

601


What are the oracle differences between nvl and coalesce

500


What is the sid in oracle?

523


What are advantages of dateset in datastage?

1738