oracle - UPDATE using collection -


i testing code in want delete table using values stored in table type variable. it's list of id. far have tried below..

declare   type rec_type table of dept.department_id%type;  t_type rec_type;  begin      select department_id bulk collect t_type         (         select department_id dept         intersect         select department_id emp      );       forall c in t_type.first..t_type.last        delete dept          department_id=t_type(c).department_id;        dbms_output.put_line(sql%rowcount);     end;    create table dept  select * departments;  create table emp  select * employees; 

but getting error

pls-00487: invalid reference variable 'dept.department_id%type' ora-06550: line 17, column 29: pl/sql: ora-22806: not object or ref ora-06550: line 16, column 8: pl/sql: sql statement ignored 06550. 00000 -  "line %s, column %s:\n%s" *cause:    pl/sql compilation error. 

not sure correct. appreciated :)

the problem here

type rec_type table of dept.department_id%type; 

is table of data type of department_id.

so not row, therefor call

t_type(c).department_id; 

is invalid, since there's no department_id in t_type(c).
reference should

t_type(c) 

instead.

although old, interesting: http://docs.oracle.com/cd/b10500_01/appdev.920/a96624/05_colls.htm


Comments

Popular posts from this blog

PHPMotion implementation - URL based videos (Hosted on separate location) -

javascript - Using Windows Media Player as video fallback for video tag -

c# - Unity IoC Lifetime per HttpRequest for UserStore -