Using %type-declarations in sql, PL-SQL Programming

Using %TYPE

The %TYPE attribute gives the datatype of a variable or the database column. In the example below, the %TYPE gives the datatype of a variable:

credit REAL(7,2);
debit credit%TYPE;

The Variables declared using %TYPE is treated such as those declared using a datatype specifier. For example, given the earlier declarations, the PL/SQL treats debit such as REAL (7, 2) variable. The later example shows that a %TYPE declaration can involve an initialization clause:

balance NUMBER(7,2);
minimum_balance balance%TYPE := 10.00;
The %TYPE attribute is mainly useful when declaring a variable which refer to a database columns. You can reference a table & column, or you can reference an owner, column, table, and as in

my_dname scott.dept.dname%TYPE;

Using the %TYPE to declare my_dname has two merits. Firstly, you do not require knowing the exact datatype of dname. Secondly, when the database definition of the dname changes, the datatype of my_dname change accordingly at the run time.

Posted Date: 10/3/2012 4:44:08 AM | Location : United States







Related Discussions:- Using %type-declarations in sql, Assignment Help, Ask Question on Using %type-declarations in sql, Get Answer, Expert's Help, Using %type-declarations in sql Discussions

Write discussion on Using %type-declarations in sql
Your posts are moderated
Related Questions
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

Managing Cursors The PL/SQL uses 2 types of cursors: implicit and explicit. The PL/SQL declares a cursor implicitly for all the SQL data manipulation statements, including th

What Is a Collection The collection is an ordered group of elements, all of similar type (for e.g. the grades for a class of students). Each element has a unique subscript whic

Controlling Cursor Variables You use 3 statements to control the cursor variable: OPEN-FOR, FETCH, & CLOSE. At First, you OPEN a cursor variable FOR a multi-row query. Then, y

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

Overloading The PL/SQL overloads the subprogram names. That is, you can use similar name for few different subprograms as long as their formal parameters differ in the number

Relational Operators and Logical Operators It prepares the ground for subsequent sections in which each specific relational operator is paired with its logical counterpart, su

Parameter and Keyword Description: cursor_name: This identifies an explicit cursor formerly declared within the present scope. cursor_variable_name: These identif

Closing a Cursor Variable The CLOSE statement disables the cursor variable. After that, the related result set is undefined. The syntax for the same is as shown below: CLOS

heap sort program in pl/sql