Aggregate assignment-declarations in sql, PL-SQL Programming

Aggregate Assignment

The %ROWTYPE declaration cannot include an initialization clause. Though, there are two ways to assign values to all fields in a record at once. At First, the PL/SQL allows the aggregate assignment between the whole records if their declarations refer to the similar table or cursor. For illustration, the assignment below is legal:

DECLARE
dept_rec1 dept%ROWTYPE;
dept_rec2 dept%ROWTYPE;
CURSOR c1 IS SELECT deptno, dname, loc FROM dept;
dept_rec3 c1%ROWTYPE;
BEGIN
...
dept_rec1 := dept_rec2;
However, because dept_rec2 is based on a table and dept_rec3 is based on a
cursor, the following assignment is illegal:
dept_rec2 := dept_rec3; -- illegal
Secondly, you can assign a list of column values to a record by using the SELECT or FETCH statement, as the illustration below shows. The column names should appear in the order in which they are defined by the CREATE TABLE or CREATE VIEW statement.


DECLARE
dept_rec dept%ROWTYPE;
...
BEGIN
SELECT deptno, dname, loc INTO dept_rec FROM dept
WHERE deptno = 30;

Posted Date: 10/3/2012 4:46:33 AM | Location : United States







Related Discussions:- Aggregate assignment-declarations in sql, Assignment Help, Ask Question on Aggregate assignment-declarations in sql, Get Answer, Expert's Help, Aggregate assignment-declarations in sql Discussions

Write discussion on Aggregate assignment-declarations in sql
Your posts are moderated
Related Questions
Deleting Objects You can use the DELETE statement to eradicate objects from an object table. To eradicate objects selectively, you use the WHERE clause, as shown below: BEG

Processing Transactions This part describes how to do the transaction processing. You learn the fundamental techniques that safeguard the consistency of your database, involvin

Albeit simple method : These all the truth tables give us our first as albeit simple method for proving a theorem: where check whether it can be written in propositional logic

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

Example of Null operator - NiNo Rule If we wanted to make HIGHER_OF adhere to "NULL in, NULL out"-let's call it the NiNo rule-we would have to write something like what is sho

Controlling Autonomous Transactions The first SQL statement in an autonomous routine starts a transaction. Whenever one transaction ends, the next SQL statement starts the oth

Relational Algebra - SQL It describes some operators, that together constitute an algebra that is not only relationally complete but also irreducibly so (very nearly- apart f

Mixed Notation The fourth procedure call shows that you can mix the positional and named notation. In this situation, the first parameter uses the positional notation, & the s

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

Write a cursor to open an employee database and fetch the employee record whose age is greater than 45