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
SQL Functions The PL/SQL uses all the SQL functions involving the following aggregate functions that summarize the whole columns of the Oracle data: GROUPING, AVG, COUNT, STDDE

This task involves developing some functions that extract data from an SQL database. The scenario is that a company which owns an online vehicle search website wants to generate so

Effects of NULL for UNIQUE Specification When a UNIQUE specification u for base table t includes a column c that is not subject to a NOT NULL constraint, the appearance of sev

Indeterminacy in SQL Some SQL expressions are actually not function invocations at all in the mathematical sense, being indeterminate-invocations operating on identical input

Explicit Cursors The set of rows returned by the query can include zero, one, or multiple rows, depending on how many rows meet your search criteria. Whenever a query returns

Transaction context As the figure shows, the major transaction shares its context with the nested transactions, but not with the autonomous transactions. Similarly, If one aut

What Is a Package? The package is a schema object that group logically related PL/SQL items, types, and subprograms. The Packages usually have 2 parts, a specification & a bo

Challenge 1 You are required to do the project and write a test plan for it. Demo 4 is a check writer program for employees. In it, the user enters all information about the

Scoping Within the similar scope, all the declared identifiers should be unique. So, even if their datatypes differ, the variables and parameters cannot share the similar name.

Declaring Exceptions The Exceptions can be declared only in the declarative part of the PL/SQL subprogram, block, or package. By introducing its name, you can declare an excep