Professional Documents
Culture Documents
Assignment Nested Table
Assignment Nested Table
A Nested Table is a type of collector, which has no limit on the number of entries per
row. It is in fact a table within a table and is represented as a column within another table
1)CREATE OBJECT
2)CREATE TYPE
EXAMPLES:
1)INSERT
INSERT INTO
TABLE(select attributes
from tbl_car_nested
where car_id = 10)
values (59,'black','hyundai',334);
update table
( select attributes
FROM tbl_car_nested
WHERE car_id=10
)ca
SET
ca.MODEL_NO=23,
ca.color='black',
ca.mfg='toyota',
ca.cost=56000
3)UPDATE BY REPALCING ALL ROWS IN REFRENCE TABLE BY ROW
SPECIFIED IN SET CLAUSE
update tbl_car_nested
set attributes= C_ATTRIB(CAR_ATTRIBUTES(
99,'voilet','tata',899))
where car_id=4
4)
update table
( select attributes
FROM tbl_car_nested
WHERE car_id=10
)ca
SET
ca.MODEL_NO=59,
ca.color='black',
ca.mfg='BMW',
ca.cost=909
5)
UPDATING PERTICULAR ROW
update table
( select attributes
FROM tbl_car_nested
WHERE car_id=10
)ca
SET ca.color='RED'
WHERE ca.MODEL_NO=60
This is the example that insert into the table from table car that have the structure nested
table column
desc car
desc car
Name Null Type
------------------------------ --------
------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------
MODELNO VARCHAR2(4000)
COLOR VARCHAR2(4000)
MFG VARCHAR2(4000)
COST NUMBER(20)
select car_id from tbl_car_nested n where exists( select attributes from tbl_car_nested
where car_id>n.car_id )
8)DELETING
/
CREATE OR REPLACE TYPE type_sub_module AS TABLE OF SUB_MODULE