Job Seekers   Employers
dbapool: Authors | Submissions | Contact Us
   Forgot password? | Sign up
  Home   Discussion Forum   Articles   Interview Questions   FAQs   Scripts   Rewards   Analyzer   White Papers   Blog   Certification   Downloads   Tools
 

Topic: SQL*Plus and PL/SQL >> Nested Table and Varray.

Disclaimer: The purpose of all dbapool forums including OCP and Other Oracle Certification forums is to help each other with specific issues but not to share dump and copyrighted exam content, materials or intellectual property. You may review the entire Oracle Certification Program Candidate Agreement online Here.



  


 Title: Nested Table and Varray.
 RAJNISH  Posted: Jul 18, 2008 08:28:45 AM

 Total Post: 92
 Joined: Jan, 2007






 Hi All,
What is Nested table and Varray.?
some body send me some example of Nested table and varray.

Thanks,
Rajnish.

 shake
Posted: Jul 21, 2008 06:49:53 AM  

 Total Post: 85
 Joined: Jun, 2008






 
Collection is an ordered group of elements, all of the same type, available in PL/SQL. It is of 3 types.
* Associative arrays or index-by tables
* Nested tables
* Varrays (Variable-size arrays)

Nested tables represent sets of values. You can think of them as
one-dimensional arrays with no upper bound. You can have multi-dimensional
arrays by creating nested tables whose elements are also nested tables.

Varrays allow you to reference individual elements for
array operations, or manipulate the collection as a whole. A varray has a maximum size, which you specify in its type definition. Its index has a
fixed lower bound of 1 and an extensible upper bound.

For more info, go through any site with examples. www.java2s.com contains many examples.


 RAJNISH
Posted: Jul 22, 2008 01:01:53 AM  

 Total Post: 92
 Joined: Jan, 2007






 
Hi Shake.
Thank u so much for reply.
but can you do favor on me can u send me some example code.
u mentioned one link but that is for Java you some link of Oracle?

--Rajnish

 puri
Posted: Jul 22, 2008 04:51:22 AM  

 Total Post: 18
 Joined: Jul, 2008






 
hi rajnish
check this. i think this will help u

A NESTED TABLE CAN BE THOUGHT OF AS A DATABASE TABLE WITH TWO COLUMNS KEY AND VALUE. NESTED TABLES MUST BE CREATED WITH SEQUENTIAL KEYS, AND THE KEYS CANNOT BE NEGATIVE. NESTED TABLES CAN BE STORED IN THE DATABASE WHILE INDEX-BY TABLES CANNOT. THE MAXIMUM NUMBER OF ROWS IN A NESTED TABLE IS 2 GIGABYTES, WHICH IS ALSO THE MAXIMUM KEY VALUE.

SYNATX:
TYPE table_name IS TABLE OF table_type[NOT NULL];
WHERE table_name is the name of the new type, and
table_type is the type of each element in the nested table. table_type can be a user-defined object type or it can be an expression using %type, but it cannot be boolean, nchar, nclob, nvarchar2, or ref cursor.


example:
declare
type numberstab is table of number;
v_tab1 numberstab:=numberstab(-1);
v_primes numberstab:=numberstab(1,2,3,5,7);
v_tab2 numberstab:=numberstab();
begin
v_tab1(1):=12345;
for v_count in 1..5 loop
dbms_output.put_line(v_primes(v_count)||' ');
end loop;
dbms_output.new_line;
end;
/

varray:
a varray is a datatype very similar to an array in c or java. it is accessed similar to a nested table however it has a fixed upper bound on its size.

syntax:
type type_name is {varray| varying array}
(max_size) of element_type[not null];

example:

DECLARE
TYPE NUMBERS IS VARRAY(20) OF NUMBER(3);
V_NULLLIST NUMBERS;
V_LIST1 NUMBERS:=NUMBERS(1,2);
V_LIST2 NUMBERS:=NUMBERS(NULL);
BEGIN
IF V_NULLLIST IS NULL THEN
DBMS_OUTPUT.PUT_LINE('V_NULLLIST IS NULL');
END IF;
IF V_LIST2(1) IS NULL THEN
DBMS_OUTPUT.PUT_LINE('V_LIST2(1) IS NULL');
END IF;
END;
/
let me know whether this is the one you want.
with ragards
kalyani

 shake
Posted: Jul 23, 2008 12:36:38 AM  

 Total Post: 85
 Joined: Jun, 2008






 
Kalyani has given good explanation with examples. I guess this could surely answer your doubts. But here is the absolute path (link) for Collection examples in java2s.
http://www.java2s.com/Tutorial/Oracle/0520__Collections/Catalog0520__Collections.htm

 RAJNISH
Posted: Jul 23, 2008 01:33:26 AM  

 Total Post: 92
 Joined: Jan, 2007






 
Hi Kalyani,
yes u r right dear these is the one i am looking for.
thank u so much.if u have some more information about these kindly send me my email address.i.e.chauhanrajnish@gmail.com
please mention your email address bcz i have some doubt so i can ask mmy query by mail.

Regards,
Rajnish.

 puri
Posted: Jul 23, 2008 02:48:45 AM  

 Total Post: 18
 Joined: Jul, 2008






 
hi rajnish,
iam happy to see ur reply
u can post your doubts here in this.. so that others can also see them


tahnks&regards
kalyani

 RAJNISH
Posted: Jul 23, 2008 05:07:47 AM  

 Total Post: 92
 Joined: Jan, 2007






 
Hi Kalyani,
can u explain me SDLC concept of oracle?

Thanks,
Rajnish

 Time Zone: EDT

  




Forum Rules & Description


Who Can Read The Forum? Any registered user or guest
Who Can Post New Topics? Any registered user
Who Can Post Replies? Any registered user




 








Get FREE Magazines

Top 10 Forum User

  Murtuja Khokhar857
  Mohammed Taj746
  positive fanatic483
  Jayanta Sur479
  Vigyan Kaushik386
  Vinoth Kumar364
  Gopu Gopi340
  Gitesh Trivedi322
  neeraj sharma258
  Ramesh Jois246






oracle Mag



  About Us Advertise Terms of Use Privacy Newsletters Contact Us    

Home   Discussion Forum   FAQs  Articles  Jobs   Newsletters  Directory  Downloads 

Our Premium Sponsor
Confio Software