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

Explain the use of ignore option in imp command.

583


What privilege is needed for a user to connect to oracle server?

569


Explain the use of online redo log files in oracle.

595


Explain oracle 12c new features for developers?

547


What is control file used for?

611






How to save query output to a local file?

566


What is an oracle tablespace?

613


How many file formats are supported to export data?

668


Explain the use of rows option in imp command.

609


What is a sub query? Describe its types?

554


How to resolve name conflicts between variables and columns?

580


What are the different types of database objects?

536


what is the use of system.effective.date variable in oracle?

681


How to do a full database export?

646


What are transaction isolation levels supported by oracle?

582