Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: PL/SQL: Clearing a Collection
On 2006-12-30, rios <rios_at_rios.com> wrote:
> 10gR2
>
> Is assigning NULL to Nested Table (to clear it) documented syntax ?
> or should it be the_nested_table_variable.DELETE ?
>
> DECLARE
> TYPE typ_emp_table IS TABLE OF scott.emp%ROWTYPE;
> l_emp_table typ_emp_table ;
> BEGIN
> select * BULK COLLECT INTO l_emp_table FROM scott.emp;
> -- l_emp_table.DELETE; or l_emp_table := NULL;
> END ;
>
> thanks
Both are correct, but have different meaning.
Depends actually what you understand by 'clearing it'.
If, what I presume, that you want l_emp_table to be without any elements, then the .delete construct is what you're after. l_emp_table is then 'empty' (a collection with no elements) but NOT NULL.
:= null makes the variable being null, so it's even 'emptier' than empty, that is, there is not even a collection 'behind' that variable.
hth
Rene
-- Rene Nyffenegger http://www.adp-gmbh.chReceived on Sat Dec 30 2006 - 04:18:56 CST