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
Using EXTEND To enlarge the size of a collection, use EXTEND. This process has 3 forms. The EXTEND appends one null element to a collection. And the EXTEND(n) appends n null e

%ISOPEN The Oracle closes the SQL cursor automatically after executing its related SQL statement. As a result, the %ISOPEN forever yields FALSE.

Using research notes and Oracle documentation plan and execute an upgrade of an installation of Oracle 10g to Oracle 11g release 1. To do this you must show in screen shots and wri

OPEN-FOR Statement The OPEN-FOR statements execute the multi-row query related with a cursor variable. It also allocates the resources used by the Oracle to process the query a

Table Comparison - SQL The following definitions for relation comparisons: Let r1 and r2 be relations having the same heading. Then: r1 ⊆ r2 is true if every tuple of r1

Multiple Assignment- SQL SQL supports multiple assignment to local variables and also applies multiple assignment semantics in SET clauses of UPDATE statements, but does not

Example of UNWRAP Operator - SQL Example here shows how unwrapping can be done in longhand in SQL. Example: Unwrapping in SQL Letting CONTACT_INFO_WRAPPED denote the res

SQL outer join SELECT * FROM IS_CALLED NATURAL LEFT JOIN IS_ENROLLED_ON Note that adding LEFT to an invocation of CROSS JOIN has no effect unless the right-hand operand

The accuracy of product table data is critical and the Brwebean's. owner wants to have an audit file that contains information regarding all DML activity on the BB_PRODUCT table. T

Use Bulk Binds If SQL statements execute inside a loop using the collection elements as bind variables, context switching between the PL/SQL & SQL engines can slow down the ex