Problem with Record datatype [message #414379] |
Tue, 21 July 2009 23:01  |
ali560045
Messages: 25 Registered: May 2009
|
Junior Member |
|
|
Below is the PL/SQL block that is showing errors.Can anyone please tell me whats the problem with it
declare
cursor c1 is select * from emp;
type emp1_record is record
(new_data emp%rowtype);
v_emp_records emp1_record;
begin
open c1;
LOOP
fetch c1 into v_emp_records;
exit when c1%notfound;
insert into emp1 values v_emp_records;
end LOOP;
close c1;
dbms_output.put_line('Done');
end;
|
|
|
|
Re: Problem with Record datatype [message #414382 is a reply to message #414379] |
Tue, 21 July 2009 23:09   |
ali560045
Messages: 25 Registered: May 2009
|
Junior Member |
|
|
Below is the ERRORS
ORA-06550: line 11, column 29:
PLS-00382: expression is of wrong type
ORA-06550: line 11, column 17:
PL/SQL: ORA-00947: not enough values
ORA-06550: line 11, column 5:
PL/SQL: SQL Statement ignored
|
|
|
|
|
|
Re: Problem with Record datatype [message #414389 is a reply to message #414387] |
Tue, 21 July 2009 23:16   |
ali560045
Messages: 25 Registered: May 2009
|
Junior Member |
|
|
See my intention is to copy the entire emp table data to table emp1, for this i m using record datatype.
I have created a table emp1 with same structure as emp table.
So whats wrong in my PL/SQL block that it is shoing the above errors
|
|
|
|
|
Re: Problem with Record datatype [message #414443 is a reply to message #414379] |
Wed, 22 July 2009 03:49  |
JRowbottom
Messages: 5933 Registered: June 2006 Location: Sunny North Yorkshire, ho...
|
Senior Member |
|
|
You don't need to mess about defining you own record types for this - in fact, as your record type is defined in Pl/Sql and not Sql, you'd be doomed to failure anyway.
Just define your record type as a Cursor%rowtype, or table%rowtype is replace your declare block with one of these:declare
cursor c1 is select * from emp;
v_emp_records c1%rowtype;
begin
... ordeclare
cursor c1 is select * from emp;
v_emp_records emp%rowtype;
begin
...
|
|
|