Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Insertion using Collections - PL/SQL: ORA-00947: not enough Values

User_3YG1KJun 16 2022

Hi ,
I have an emp table wit below column structure..
create table emp(
emp_id number,
emp_name varchar2(30),
emp_sal number(8,2),
dept_id number,
hiredate date,
comm number(4,2),
analysed_date date,
gender char(1),
email varchar2(50));
---> empVV is another table of samestructure of emp table.
now ---> I am inserting the data into table empVV using emp using aProcedure by using collections. I have cross cecked several times , but could not find the error....

create or replace noneditionable procedure Associative_or_Index_by_Tables Is
Type AsscArrysTyp Is Table Of emp%Rowtype Index By Pls_Integer;
v_AsscArrysTyp AsscArrysTyp;
idx Pls_Integer;
Begin
For i In 1..20
Loop
Select e.* Into v_AsscArrysTyp(i) From emp e Where emp_id=i;
End Loop;
idx:= v_AsscArrysTyp.FIRST;
While idx Is Not Null
Loop
dbms_output.put_line(v_AsscArrysTyp(idx).emp_id ||','||
v_AsscArrysTyp(idx).emp_name ||','||
v_AsscArrysTyp(idx).emp_sal ||','||
v_AsscArrysTyp(idx).dept_id ||','||
v_AsscArrysTyp(idx).hiredate ||','||
v_AsscArrysTyp(idx).comm ||','||
v_AsscArrysTyp(idx).analysed_date ||','||
v_AsscArrysTyp(idx).gender ||','||
v_AsscArrysTyp(idx).email
);
Insert Into empvv(emp_id,
emp_name,
emp_sal,
dept_id,
hiredate,
comm,
analysed_date,
gender,
email
)
Values (v_AsscArrysTyp(idx).emp_id ||','||

         v\_AsscArrysTyp(idx).emp\_name ||','||  
         v\_AsscArrysTyp(idx).emp\_sal ||','||  
         v\_AsscArrysTyp(idx).dept\_id ||','||  
         v\_AsscArrysTyp(idx).hiredate ||','||  
         v\_AsscArrysTyp(idx).comm ||','||  
         v\_AsscArrysTyp(idx).analysed\_date ||','||  
         v\_AsscArrysTyp(idx).gender ||','||  
         v\_AsscArrysTyp(idx).email  
         );  

Commit;

idx:=v_AsscArrysTyp.NEXT(idx); ----- NEXT Usage
End Loop;
end Associative_or_Index_by_Tables;

I have been passing same no of values but , I am still getting the same error
Error------> Compilation errors ASSOCIATIVE_OR_INDEX_BY_TABLES
Error: PL/SQL: ORA-00947: not enough values
Line: 259
Text: Values (v_AsscArrysTyp(idx).emp_id ||','||

Error: PL/SQL: SQL Statement ignored
Line: 249
Text: Insert Into empvv(emp_id,

Please let me know where am i going wrong ..
Thanks for the timely reply...

This post has been answered by User_3YG1K on Jun 16 2022
Jump to Answer
Comments
Post Details
Added on Jun 16 2022
2 comments
518 views