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
Short-Circuit Evaluation When computing a logical expression, the PL/SQL uses short-circuit evaluation. That is, the PL/SQL stops computing the expression as soon as the result

Positional Notation The first procedure call uses the positional notation. The PL/SQL compiler relates the first actual parameter, account, with the first proper parameter, ac

Exceptions An exception is the runtime error or warning condition that can be predefined or user-defined. The Predefined exceptions are raised implicitly through runtime system

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

In Packages The Forward declarations also group logically related subprograms in the package. The subprogram specifications go in the package specification, & the subprogram b

Procedures The procedure is a subprogram which can take parameters and be invoked. Normally, you can use a procedure to perform an action. The procedure has 2 sections: the spe

I need to write one function and one procedure to query a Oracle 10.1 DB using PL SQL. I have the schema and exact queries...along with work Ive started and a template to put the a

SELECT INTO Statement   The SELECT INTO statement retrieve data from one or more database tables, and then assigns the selected values to the variables or fields. Syntax:

EXECUTE IMMEDIATE Statement   The EXECUTE IMMEDIATE statement prepare (parses) and instantly executes a dynamic SQL statement or an anonymous PL/SQL block. Syntax:

Task 2 [12 marks] Write the package body for the following package specification (the detailed description of each function and procedure is provided in the appendix below). Place