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
Assignments in pl/sql The Variables and constants are initialized every time a block or subprogram is entered. By default, the variables are initialized to NULL. Therefore, unle

Redeclaring Predefined Exceptions Keep in mind that, the PL/SQL declares predefined exceptions globally in the package STANDARD; Therefore you need not declare them yourself.

Closest Approximation to Relational Union - SQL Actually, just as SQL has several varieties of JOIN, it also has several varieties of UNION, none of which is equivalent to th

Datatype Conversion At times it is necessary to convert a value from one datatype to another. For e.g. if you want to inspect a rowid, you should convert it to a character stri

IF Statement The IF statement executes a series of statement conditionally. Whether the series is executed or not depends on the value of the Boolean expression. Syntax:

Demonstrate your knowledge of PL/SQL programming by writing and thoroughly testing triggers and stored procedures associated with an e-commerce application that provides security l

Name Resolution   During the compilation, the PL/SQL compiler relates identifiers like the name of a variable with an address or memory location, actual value, or datatype. Th

Using the FORALL Statement The keyword FORALL instruct the PL/SQL engine to bulk-bind input collections before sending them all to the SQL engine. Though the FORALL statement

Using NOT NULL Besides assigning an initial value, the declarations can impose the NOT NULL constraint, as the example below shows: acct_id INTEGER(4) NOT NULL := 9999; You ca

Declaring Cursor Variables Once a REF CURSOR type is define by you, and then you can declare the cursor variables of that type in any PL/SQL block or subprogram. In the exampl