Select data into rowtype variable : rowtype « PL SQL « Oracle PL / SQL






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

1.Use select command to fill value to rowtype variable
2.Define row type variable
3.Define rowtype and reference its column value
4.rowtype index by binary_integer
5.Use rowtype type value to query a table
6.Cursor and rowtype
7.For each row in the cursor
8.From Fields to Rows-Using %ROWTYPE
9.Insert table%rowtype to table
10.Rowtype variable
11.Select * into table%rowtype
12.fetch sys_refcursor type variable to table%rowtype variable