Home » SQL & PL/SQL » SQL & PL/SQL » retrieving values from objects
retrieving values from objects [message #195380] Thu, 28 September 2006 05:45 Go to next message
navkrish
Messages: 189
Registered: May 2006
Location: NJ,USA
Senior Member

Got stuck while retrieving values from objects

TYPE Definition:

type varchar_table as table of varchar2(255);
/

TYPE RING_OTP AS
 OBJECT 
 (
  RING_VALUES 	   		varchar_table,
  DA_ASSIGNED 			DATE
 
 )
/

type ring_ntt as table of ring_otp;
/


code:
declare

   rat_ntt	   ring_ntt;


begin
   rat_ntt:= ring_ntt(ring_otp(varchar_table('A++','r','XIII'),sysdate-3),
   			 		  ring_otp(varchar_table('AA-'),sysdate-2),
					  ring_otp(varchar_table('A','2'),sysdate-1),
					  ring_otp(varchar_table('BBg'),sysdate)
					   );
      		
		for ind in rat_ntt.first ..rat_ntt.last
		loop
		      
 	      dbms_output.put_line( rat_ntt(ind).DA_ASSIGNED );
		 
		end loop;	   


end;
/



output:

25-SEP-06
26-SEP-06
27-SEP-06
28-SEP-06


But I need the output as

A++    
r   
XIII    
25-SEP-06
AA-    
26-SEP-06
A
2
27-SEP-06
BBg
28-SEP-06



How to retrieve values from varchar_table?

Naveen
Re: retrieving values from objects [message #195394 is a reply to message #195380] Thu, 28 September 2006 06:48 Go to previous message
Cthulhu
Messages: 381
Registered: September 2006
Location: UK
Senior Member
declare
   rat_ntt	   ring_ntt;
   ind2        varchar2(255);
begin
   rat_ntt:= ring_ntt(ring_otp(varchar_table('A++','r','XIII'),sysdate-3),
   			 		  ring_otp(varchar_table('AA-'),sysdate-2),
					  ring_otp(varchar_table('A','2'),sysdate-1),
					  ring_otp(varchar_table('BBg'),sysdate)
					   );	
   for ind in rat_ntt.first ..rat_ntt.last loop
      dbms_output.put_line( rat_ntt(ind).DA_ASSIGNED );
      ind2 := rat_ntt(ind).RING_VALUES.first;
      while ind2 is not null loop
         dbms_output.put_line(rat_ntt(ind).ring_values(ind2));
         ind2 := rat_ntt(ind).RING_VALUES.next(ind2);
      end loop;
   end loop;	  
end;
Previous Topic: Whats wrong with query.
Next Topic: second case issue
Goto Forum:
  


Current Time: Thu Dec 08 14:26:40 CST 2016

Total time taken to generate the page: 0.09455 seconds