List %rowtype and type record along with their applications



Download 47.1 Kb.
Date22.11.2021
Size47.1 Kb.

List %ROWTYPE and TYPE RECORD along with their applications



%ROWTYPE is an attribute to inherit datatypes of attributes of a table into a RECORD variable.



TYPE RECORD is a keyword to create record type using either explicitly specifying attributes or by implecitly inheriting attributes from a table or an existing cursor.

% ROWTYPE is to be used whenever query returns an entire row of a table or view.
TYPE rec RECORD is to be used whenever query returns columns of different table or views and variables.
E.g. TYPE r_emp is RECORD (eno emp.empno% type,ename emp ename %type );
e_rec emp% ROWTYPE
cursor c1 is select empno,deptno from emp;
e_rec c1 %ROWTYPE.

One more point: When we have a variable of typer RECORD we have declare additional variables but with %rowtype, we can only have the fields that are present in the table.

%ROWTYPE application: The %ROWTYPE attribute helps in creating table and cursor based records. It is useful to retrieve an entire row from a table. If you do not use the %ROWTYPE datatype, then you have to declare variables for each column separately.

TYPE RECORD application: The data you use in Vision applications generally is in the form of standard Ingres character, numeric, date or money data types. However, you also can combine these data types to create your own data types, called record types.

A record type combines related components of data into a single value. Using a record type increases the efficiency and performance of your application by letting you retrieve, store, or pass multiple data items as a single item.

After you define a record type, you can use it in your application in various ways:

•In a local or global variable definition

•In a global constant definition

•In escape code

•As a parameter passed between frames

TYPE RECORD is a composite datatype. It consits of multiple pieces of information, called fields. TYPE RECORD fields can be defined by the user. Eg:

DECLARE

TYPE extra_book_info_t

IS RECORD (

title books.title%TYPE,

is_bestseller BOOLEAN

);

first_book extra_book_info_t;

here, 'title' is the data type defined in books table. We can declare a RECORD based on this type.

Where as %ROWTYPE is a direct link to the data type of the table.columns, EG:

DECLARE

bestseller books%ROWTYPE;

The advantage of TYPE RECORDS is you can pass these to Functions or Procedures which can reduce the parameter size or a repitative work
Download 47.1 Kb.

Share with your friends:




The database is protected by copyright ©ininet.org 2020
send message

    Main page