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

Using %ROWTYPE

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.

DECLARE
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:
BEGIN
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
Boolean Values Only the values TRUE, FALSE, & NULL can be assigned to a Boolean variable. For illustration, given the declaration DECLARE done BOOLEAN; the following statements

Controlling Cursor Variables You use 3 statements to control the cursor variable: OPEN-FOR, FETCH, & CLOSE. At First, you OPEN a cursor variable FOR a multi-row query. Then, y

Many of the reports generated from the system calculate the total dollars in purchases for a shopper. Complete the following steps to create a function named TOT_PURCH_SF that acce

Using SAVEPOINT The SAVEPOINT names and marks the present point in the processing of a transaction. Used with the ROLLBACK TO statement, the savepoints undo parts of a transac

Parameter and Keyword Description: cursor_name: This identifies an explicit cursor formerly declared within the present scope. cursor_variable_name: These identif

Operator Precedence The operations within an expression are completed in a particular order depending on their precedence (priority). The table shows the default order of the op

Pl/sql Conditional Control: IF statements Frequently, it is necessary to take the alternative actions depending on the circumstances. The IF statement execute a series of statem

Datatypes Every constant and variable has a datatype that specifies the storage format, constraints, and the valid range of values. The PL/SQL gives a variety of predefined dat

Write a pl/sql block that declares and uses cursors with parameters. In a loop, use a cursor to retrieve the department number and the department name from the departments table

Advantages of Invoker Rights The Invoker-rights routines centralize the data retrieval. They are particularly helpful in applications which store data in various schemas. In su