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
Magento change address format depending on store Project Description: What I need is that depending on the store in which the customer bought the address should change the fo

1- You can check attribute names from each table in DBF11 by running for example:  desc dbf11.Member;  desc dbf11.Agent;  desc dbf11.Producer; Because some attribute names in

Package STANDARD The package named STANDARD defines the PL/SQL atmosphere. The package specification globally declares the exceptions, types, and subprograms that are available

I need SQL to infopath data connection Project Description: Want data retrieval connection from SQL to SharePoint infopath Skills required are Sharepoint, SQL

TTITLE and BTITLE are commands in Pl-SQL to control report headings and footers. This Ttitle & Btitle are mainly used on creating SQL*PLUS report. Ttitle is used for toptitle headi

Read-Only Operator (+) - SQL The term read-only operator to the mathematical term function. Here I just need to add that the SQL standard reserves the term function for read-

Naming Conventions The similar naming conventions apply to all PL/SQL program items and units including the variables, cursors, constants, cursor variables, procedures, exception

Difference between 9i & 10G When Oracle releases any new databases then it are having some discrepancy with them. But 10G is having much difference than oracle 9i has. Oracle

Variable Declaration - SQL SQL's support for variables is very similar to Tutorial D's, except that the syntax for creating persistent  variables-base tables-is quite differen

Implicit Cursors The Oracle implicitly opens a cursor to process each SQL statement not related with an explicitly declared cursor. The PL/SQL lets you refer to the most recen