Home » SQL & PL/SQL » SQL & PL/SQL » PL/SQL Records
PL/SQL Records [message #189042] Wed, 23 August 2006 00:00 Go to next message
mikemc
Messages: 4
Registered: August 2006
Junior Member
PL/SQL Records-Must contain one or more components of any scalar,RECORD, or INDEX BY table data type, called fields.

How do i involve a INDEX BY table data type as a field in a record definition?

set serveroutput on
declare
type rec_tab_type is table of employees.last_name%type index by binary_integer;
type rec_type is record(rec1 rec_tab_type);
begin
select last_name into rec_type from employees;
dbms_output.put_line(rec_type.rec1);
end;

/
I get the following error

select last_name into rec_type from employees;
*

ERROR at line 5:
ORA-06550: line 5, column 25:
PLS-00321: expression 'REC_TYPE' is inappropriate as the left hand side of an assignment statement
ORA-06550: line 5, column 34:
PL/SQL: ORA-00904: : invalid identifier
ORA-06550: line 5, column 3:
PL/SQL: SQL Statement ignored
ORA-06550: line 6, column 24:
PLS-00330: invalid use of type name or subtype name
ORA-06550: line 6, column 3:
PL/SQL: Statement ignored


Could some one help me out?
Re: PL/SQL Records [message #189049 is a reply to message #189042] Wed, 23 August 2006 00:27 Go to previous message
Frank
Messages: 7880
Registered: March 2000
Senior Member
rec_type is a datatype. Just as well as you cannot use
select 'A' into varchar2 from dual, you cannot select directly into rec_type.
You have to declare a variable of type rec_type and use that.

An index by table datatype could be used in a record when you create a nested table, e.g. a record containing customer data plus per customer n addresses.
Previous Topic: how to debug pl/sql code
Next Topic: Having trouble understanding EXISTS clause
Goto Forum:
  


Current Time: Fri Dec 09 23:38:08 CST 2016

Total time taken to generate the page: 0.11596 seconds