1.ORA-06531: 引用未初始化的收集
wf@ORA10> edit 已写入 file afiedt.buf 1 declare 2 type aaa is table of number; 3 v_ray aaa; 4 begin 5 v_ray(1):=1; 6* end; wf@ORA10> / declare * 第 1 行出现错误: ORA-06531: 引用未初始化的收集 |
使用前需要对数组进行初始化
2. ORA-06533: 下标超出数量
wf@ORA10> edit 已写入 file afiedt.buf 1 DECLARE 2 TYPE emp_ssn_array IS TABLE OF NUMBER; 3 best_employees emp_ssn_array:=emp_ssn_array(); 4 BEGIN 5 best_employees(1) := '123456'; 6* END; wf@ORA10> / DECLARE * 第 1 行出现错误: ORA-06533: 下标超出数量 ORA-06512: 在 line 5 |
解决方法:
wf@ORA10> edit 已写入 file afiedt.buf 1 DECLARE 2 TYPE emp_ssn_array IS TABLE OF NUMBER; 3 best_employees emp_ssn_array:=emp_ssn_array(5); 4 BEGIN 5 best_employees.extend; 6 best_employees(1) := 1; 7 best_employees(2) := 2; 8* END; wf@ORA10> / PL/SQL 过程已成功完成。 |
3 PLS-00642: 在 SQL 语句中不允许使用本地收集类型
wf@ORA10> edit 已写入 file afiedt.buf 1 DECLARE 2 TYPE emp_ssn_array IS TABLE OF NUMBER; 3 best_employees emp_ssn_array:=emp_ssn_array(5); 4 BEGIN 5 best_employees.extend; 6 best_employees(1) := 1; 7 best_employees(2) := 2; 8 best_employees(3) := 3; 9 best_employees(4) := 4; 10 best_employees(5) := 5; 11 select max(t) from table(best_employees) t; 12* END; wf@ORA10> / select max(t) from table(best_employees) t; * 第 11 行出现错误: ORA-06550: 第 11 行, 第 26 列: PLS-00642: 在 SQL 语句中不允许使用本地收集类型 ORA-06550: 第 11 行, 第 20 列: PL/SQL: ORA-22905: 无法从非嵌套表项访问行 ORA-06550: 第 11 行, 第 1 列: PL/SQL: SQL Statement ignored |
解决方法:在模式中先定义数组,然后在过程中使用.
wf@ORA10> create type aaa is table of number; 2 / 类型已创建。
|
4 PL/SQL: ORA-00932: 数据类型不一致: 应为 -, 但却获得 WF.AAA
wf@ORA10> edit 已写入 file afiedt.buf 1 declare 2 v_ray aaa:=aaa(); 3 v_max int; 4 v_min int; 5 begin 6 v_ray.extend(3); 7 v_ray(1):=1; 8 v_ray(2):=2; 9 v_ray(3):=3; 10 select max(v_ray) into v_max from table(v_ray); 11 dbms_output.put_line(v_max); 12* end; wf@ORA10> / select max(v_ray) into v_max from table(v_ray); * 第 10 行出现错误: ORA-06550: 第 10 行, 第 12 列: PL/SQL: ORA-00932: 数据类型不一致: 应为 -, 但却获得 WF.AAA ORA-06550: 第 10 行, 第 1 列: PL/SQL: SQL Statement ignored |
解决方法:在数组对象中使用伪列"column_value"
wf@ORA10> edit 已写入 file afiedt.buf 1 declare 2 v_ray aaa:=aaa(); 3 v_max int; 4 v_min int; 5 begin 6 v_ray.extend(3); 7 v_ray(1):=1; 8 v_ray(2):=2; 9 v_ray(3):=3; 10 select max(column_value) into v_max from table(v_ray); 11 select min(column_value) into v_min from table(v_ray); 12 dbms_output.put_line('最大值:'||v_max); 13 dbms_output.put_line('最小值:'||v_min); 14* end; wf@ORA10> / 最大值:3 最小值:1 PL/SQL 过程已成功完成。
|
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/765951/viewspace-670996/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/765951/viewspace-670996/