table type usage sample:

itpremier發表於2010-09-19

1, create or replace type ename_tab as table of varchar2(30) ;
2,

set serverout on
declare
p1 ename_tab ;
p2 ename_tab ;
begin

p1 :=ename_tab('') ;
--p2 :=ename_tab('') ;

p1.extend(2);
-- p2.extend(1);

p1(1) := 'Jack' ;
p1(2) := 'Mikel' ;
p1(3) := 'Dameon' ;

p2 := p1 ;

p2(1) := 'Jack-- 1' ;
p2(2) := 'Mikel--2' ;
p2(3) := 'Dameon--3' ;

dbms_output.put_line(p1(1)) ;
dbms_output.put_line(p1(2)) ;
dbms_output.put_line(p1(3)) ;
-- dbms_output.put_line(d) ;
end;
/
3, Conclusion:

1, the table type variable must be initizlize as like : tab_type('').

2, table variable Can be assigned directly just like scaler variable, and the assigned tab var is not required to initialized.

3, the assigned tab var and source tab var occupies difference memory space address.

[@more@]

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/350519/viewspace-1038604/,如需轉載,請註明出處,否則將追究法律責任。

相關文章