%ROWTYPE datatype advantages - PL/SQL Datatypes

Q.  What is the advantage of using the %ROWTYPE datatype?
- Published on 09 Jul 15

a. 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.
b. It can be used even if data type of the table columns is not known.
c. It ensures that data type of the variable changes dynamically if the underlying table is altered.
d. All mentioned above
e. Both A & B

ANSWER: All mentioned above
 

    Discussion

  • aditya   -Posted on 19 Apr 22
    a. 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.
    This is correct, By %ROWTYPE you can declare all columns of the underlying table (or view, curser, curser variable) together by a single command.
    b. It can be used even if data type of the table columns is not known.
    This is correct, Datatype and other column properties, like size etc., but not all, of the columns in record variable are inherited from the underlying table.
    c. It ensures that data type of the variable changes dynamically if the underlying table is altered
    This is correct, if any change in the table columns definition, it will reflect dynamically to columns of the record defined by %ROWTYPE plsql variable.

Post your comment / Share knowledge


Enter the code shown above:

(Note: If you cannot read the numbers in the above image, reload the page to generate a new one.)