Plsql PL/SQL:I不';我不知道如何正确地将数据插入到2列对象类型的嵌套表中。错误:";没有足够的价值观”;
我的代码:Plsql PL/SQL:I不';我不知道如何正确地将数据插入到2列对象类型的嵌套表中。错误:";没有足够的价值观”;,plsql,Plsql,我的代码: create or replace type imb_rec is object(cod number, job varchar2(20)); create or replace type tab_imbr is table of imb_rec; alter table dept_ast add info tab_imbr; declare v_imb tab_imbr := tab_imbr(); i number:=10; v_rec imb_rec; beg
create or replace type imb_rec is object(cod number, job varchar2(20));
create or replace type tab_imbr is table of imb_rec;
alter table dept_ast add info tab_imbr;
declare
v_imb tab_imbr := tab_imbr();
i number:=10;
v_rec imb_rec;
begin
while i<=270 loop
v_imb.extend;
select employee_id, job_id bulk collect into v_imb
from emp_ast
where department_id=i;
update dept_ast
set info=v_imb
where department_id=i;
delete v_imb;
i:=i+10;
end loop;
for i in 1..dept_ast.count loop
dbms_output.put_line('Codul departmentului: '||dept_ast(i).department_id);
dbms_output.put_line('Angajatii: '||dept_ast(i).department_id);
for j in 1..dept_ast(i).info.count loop
dbms_output.put_line('Codul ang: '||dept_ast(i).info(j).cod||', job: '||dept_ast(i).info(j).job);
end loop;
end loop;
end;
/
“我的部门”上表包含以下列:
DEPARTMENT_ID NUMBER(4,0)
DEPARTMENT_NAME VARCHAR2(30 BYTE)
MANAGER_ID NUMBER(6,0)
LOCATION_ID NUMBER(4,0)
我想在对象的嵌套表的dept_ast类型中添加一个新列,该对象有两列:
EMPLOYEE_ID NUMBER(6,0)
JOB_ID VARCHAR2(10 BYTE)
基本上,我希望在我的dept_ast表中有一个新列,该列将是在该特定部门工作的员工的集合。dept\u ast中的每一行都是关于一个部门的信息。我自己更正了代码:
create or replace type imb_rec is object(cod number, job varchar2(20));
create or replace type tab_imbr is table of imb_rec;
alter table dept_ast add info tab_imbr nested table info store as info_t;
rollback;
set serveroutput on
select *
from dept_ast;
declare
v_imb tab_imbr := tab_imbr();
i number:=10;
v_rec imb_rec;
type code_dep is table of dept_ast.department_id%type;
code_dep_t code_dep:=code_dep();
begin
select department_id
bulk collect into code_dep_t
from dept_ast;
while i<=270 loop
v_imb.extend;
from emp_ast
where department_id=i;
update dept_ast
set info=v_imb
where department_id=i;
v_imb.delete;
i:=i+10;
end loop;
for i in 1..code_dep_t.count loop
dbms_output.put_line('Codul departmentului: '||code_dep_t(i));
select imb_rec(employee_id, job_id)
bulk collect into v_imb
from emp_ast
where department_id=code_dep_t(i);
for j in 1..v_imb.count loop
dbms_output.put_line('Codul ang: '||v_imb(j).cod||', job: '||v_imb(j).job);
end loop;
v_imb.delete;
end loop;
end;
/
创建或替换类型imb_rec is object(cod编号,job varchar2(20));
创建或替换类型选项卡\u imbr是imb记录的表;
更改表格部门添加信息选项卡将嵌套表格信息存储为信息;
回降;
将服务器输出设置为on
挑选*
来自部门;
声明
v_imb tab_imbr:=tab_imbr();
i编号:=10;
v_rec imb_rec;
类型代码\u dep是部门id%类型的表;
code_dep_t code_dep:=code_dep();
开始
选择部门id
批量收集到代码部门
来自部门;
而我可以提供完整的错误堆栈和已执行的pl/sql脚本。另外,你能描述一下桌子的部门吗?我补充了细节。
create or replace type imb_rec is object(cod number, job varchar2(20));
create or replace type tab_imbr is table of imb_rec;
alter table dept_ast add info tab_imbr nested table info store as info_t;
rollback;
set serveroutput on
select *
from dept_ast;
declare
v_imb tab_imbr := tab_imbr();
i number:=10;
v_rec imb_rec;
type code_dep is table of dept_ast.department_id%type;
code_dep_t code_dep:=code_dep();
begin
select department_id
bulk collect into code_dep_t
from dept_ast;
while i<=270 loop
v_imb.extend;
from emp_ast
where department_id=i;
update dept_ast
set info=v_imb
where department_id=i;
v_imb.delete;
i:=i+10;
end loop;
for i in 1..code_dep_t.count loop
dbms_output.put_line('Codul departmentului: '||code_dep_t(i));
select imb_rec(employee_id, job_id)
bulk collect into v_imb
from emp_ast
where department_id=code_dep_t(i);
for j in 1..v_imb.count loop
dbms_output.put_line('Codul ang: '||v_imb(j).cod||', job: '||v_imb(j).job);
end loop;
v_imb.delete;
end loop;
end;
/