Using %rowtype-declarations in sql, PL-SQL Programming


The %ROWTYPE attribute gives a record type which represents a row in a table (or view). The record can store the whole row of data selected from the table or fetched from a cursor or strongly typed cursor variable. In the illustration below, you declare two records. The first record stores a row selected from an emp table. The second record stores a row that is fetched from the cursor c1.

emp_rec emp%ROWTYPE;
CURSOR c1 IS SELECT deptno, dname, loc FROM dept;
dept_rec c1%ROWTYPE;

The Columns in a row and corresponding fields in a record have the same names and
datatypes. Though, fields in a %ROWTYPE record do not inherit the NOT NULL column constraint.
In the example below, you select column values into record emp_rec:
SELECT * INTO emp_rec FROM emp WHERE...

Posted Date: 10/3/2012 4:45:48 AM | Location : United States

Related Discussions:- Using %rowtype-declarations in sql, Assignment Help, Ask Question on Using %rowtype-declarations in sql, Get Answer, Expert's Help, Using %rowtype-declarations in sql Discussions

Write discussion on Using %rowtype-declarations in sql
Your posts are moderated
Related Questions
Use the RETURNING Clause Frequently, the application requires information about the row affected by a SQL operation, for illustration, to produce a report or take a subsequent

Create a procedure named STATUS_SHIP_SP that allows a company to employee in the Shipping Department to update the status of an order to add shipping information. The BB_BASKETSTAT

Type versus Representation Confusion in SQL This describes how a value might have two or more distinct representations. For example, user-defined type POINT might have a decla

Example of Tables within a Table - SQL Example: Obtaining C_ER from COURSE and EXAM_MARK SELECT CourseId, CAST (TABLE (SELECT DISTINCT StudentId, Mark FROM EXAM_MARK AS EM

TYPES OF EVOLUTION - Sequential evolution                  :                    Minor changes in the gene pool of a population from one generation to the next, with the resul

"Not Enforced" Table Constraints A constraint that is not enforced is not really a constraint within the meaning of the act, but SQL does have such a concept and it needs to b

Parameter and Keyword Description: record_type_name: This identifies the user-defined type specifier that is used in the subsequent declarations of the records. NOT N

Datatype Conversion At times it is necessary to convert a value from one datatype to another. For e.g. if you want to inspect a rowid, you should convert it to a character stri

Example of Table Literal - SQL Example: A Table Literal (correct version) VALUES ('S1', 'C1', 'Anne'), ('S1', 'C2', 'Anne'), ('S2', 'C1', 'Boris'), ('S3', 'C3'