Re: Emptying a PL/SQL TABLE
Date: 1996/07/31
Message-ID: <31FEDB72.2091_at_cps.msu.edu>#1/1
Charles Jardine wrote:
>
> In the PL/SQL User's Guide and Reference (Release 2.2), on
> p. 2-43, it says:
>
> > However, you can use a simple workaround to delete an entire
> > PL/SQL table. Simply assign NULL to it, as shown in the following
> > example:
>
> However, as the following transcript shows, you can't assign
> NULL to a PL/SQL table. I guess the manual is wrong :-(
>
> Does anyone know if it is, in fact, possible to empty a PL/SQL
> table?
>
> Connected to:
> Oracle7 Server Release 7.2.3.0.0 - Production Release
> PL/SQL Release 2.2.3.0.0 - Production
>
> SQL> DECLARE
> 2 TYPE mytype IS TABLE OF NUMBER INDEX BY BINARY_INTEGER;
> 3 mytable mytype;
> 4 BEGIN
> 5 mytable := NULL;
> 6 END;
> 7 /
> mytable := NULL;
> *
> ERROR at line 5:
> ORA-06550: line 5, column 14:
> PLS-00382: expression is of wrong type
> ORA-06550: line 5, column 3:
> PL/SQL: Statement ignored
Try this:
DECLARE
TYPE mytype IS TABLE OF NUMBER INDEX BY BINARY_INTEGER;
mytable mytype;
empty_table mytype;
BEGIN
- fill mytable with data
- now empty it mytable := empty_table; END;