Select data into rowtype variable
SQL> -- create demo table
SQL> create table emp(
2 ID VARCHAR2(4 BYTE) NOT NULL,
3 fname VARCHAR2(10 BYTE),
4 lname VARCHAR2(10 BYTE),
5 Start_Date DATE,
6 End_Date DATE,
7 Salary Number(8,2),
8 City VARCHAR2(10 BYTE),
9 Description VARCHAR2(15 BYTE)
10 )
11 /
Table created.
SQL>
SQL>
SQL> declare
2 empCount number;
3 i number;
4 empRow emp%rowtype;
5 begin
6 select * into empRow from emp;
7 EXCEPTION
8 WHEN no_data_found then
9 raise_application_error (-20052,'No data!');
10 WHEN others then
11 raise_application_error (-20999,'Something wrong');
12 end;
13 /
SQL> drop table emp;
Table dropped.
SQL>
Related examples in the same category