SQL> set serveroutput on
SQL> set echo on
SQL> -- create demo table
SQL> create table Employee(
2 ID VARCHAR2(4 BYTE) NOT NULL,
3 First_Name VARCHAR2(10 BYTE),
4 Salary Number(8,2)
5 )
6 /
Table created.
SQL>
SQL> -- prepare data
SQL> insert into Employee(ID, First_Name, Salary)
2 values ('01','Jason', 1234.56)
3 /
1 row created.
SQL> insert into Employee(ID, First_Name, Salary)
2 values('02','Alison', 6661.78)
3 /
1 row created.
SQL>
SQL> -- display data in the table
SQL> select * from Employee
2 /
ID FIRST_NAME SALARY
---- ---------- ----------
01 Jason 1234.56
02 Alison 6661.78
SQL>
SQL> SET ECHO ON
SQL>
SQL> DECLARE
2 TYPE EmployeeTypee IS RECORD (
3 id employee.id%type,
4 name employee.first_name%type,
5 salary employee.salary%type
6 );
7
8 emp EmployeeTypee;
9 BEGIN
10 SELECT * INTO emp
11 FROM employee
12 WHERE id = 2;
13
14 DBMS_OUTPUT.PUT_LINE('emp_record.id: ' || emp.id);
15 DBMS_OUTPUT.PUT_LINE('emp_record.id: ' || emp.name);
16 DBMS_OUTPUT.PUT_LINE('emp_record.id: ' || emp.salary);
17 END;
18 /
emp_record.id: 02
emp_record.id: Alison
emp_record.id: 6661.78
PL/SQL procedure successfully completed.
SQL>
SQL> -- clean the table
SQL> drop table Employee
2 /
Table dropped.
SQL>