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
User-Defined Exceptions The PL/SQL defines the exceptions of your own. Dissimilar to the predefined exceptions, the user-defined exceptions should be declared and should be rai

ROWNUM The ROWNUM returns a number representing the order in which a row was selected from the table. The first row selected has a ROWNUM of 1; the second row has a ROWNUM of

Second Step at defining type SID in SQL CREATE TYPE SID AS VARCHAR(5) ; Explanation: TYPE SID announces that a type named SID is being defined to the system.

Example of NOT EXISTS Operator - SQL Example is a translation into SQL of the corresponding example, which is included there merely to show that for any scalar comparison the

Conditionals - SQL At first sight SQL does not appear to have a single operator for expressing logical implication. In this respect it would be in common with most programming

Initializing and Referencing Collections Until you initialize a collection, a nested table or varray is automatically null (i.e. the collection itself is null, not its elements)

Manipulating Individual Elements Faraway you have manipulated an entire collection. Within the SQL, to manipulate the individual elements of the collection, and then use the ope

When Are Constraints Checked Under the model constraints are conceptually checked at all statement boundaries (and only at statement boundaries). By default the same is true

i NEED TO CREATE 3 guiS IN pl/sql sERVER PAGE FORM

SSRS Report Writing Project Description: This report is part of a larger project to make a SQL Server Reporting Service (SSRS) based reporting solution. There can be more rep