Avatar of Swaminathan K
Swaminathan K
Flag for India asked on

Not able to store the rows returned by a select statement in a nested table in plsql

Hi Team,

I have written the below code to store the data returned from a select into nested table in PLSQL. When I run the code, I am getting the error mentioned below. Any help is really appreciated.

create or replace type tr_empdata is object
(
 empid number(10),
 ename varchar2(80)
);

create or replace type nt_emp is table of tr_empdata;
declare
l_empdata nt_emp;
begin
Select employee_id , concat(first_name||' ',last_name) ename into l_empdata
from employees;
end;
/

Error:
Error starting at line 8 in command:
declare
l_empdata nt_emp;
begin
Select employee_id , concat(first_name||' ',last_name) ename into l_empdata
from employees;
end;
Error report:
ORA-06550: line 4, column 77:
PL/SQL: ORA-00947: not enough values
ORA-06550: line 4, column 1:
PL/SQL: SQL Statement ignored
06550. 00000 -  "line %s, column %s:\n%s"
*Cause:    Usually a PL/SQL compilation error.
*Action:



* Oracle PL/SQLOracle Database

Avatar of undefined
Last Comment
Sean Stuber

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Sean Stuber

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy