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
What Is a Record  ? A record is a group of related data items that stored in the fields, each with its own name and datatype. Assume that you have different data about an em

I need a query for PL/SQL, selecting names with cursor, goes down the list, assigns usernames (initials001) based on initials in the name. If two names have same initials the user

MILLER-UREY' S EXPERIMENTAL PROCEDURES - They recreated the probable conditions on the primitive earth in the laboratory. An atmosphere containing hydrogen, ammonia, me

Creating a Table Syantax: CREATE TABLE ENROLMENT (StudentId SID, Name   VARCHAR (30) NOT NULL, CourseId CID, PRIMARY KEY (StudentId, CourseId)) ; Explan

Important Distinctions The list of important distinctions are given below: Value versus variable Syntax versus semantics Variable versus variable reference

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

Main features of PL/SQL A good way to get familiar with PL/SQL is to look at a sample program. The below program processes an order for tennis rackets. At first, it declares a

Advantages of Invoker Rights The Invoker-rights routines centralize the data retrieval. They are particularly helpful in applications which store data in various schemas. In su

Problem: (a) Define the following terms: (i) data mining. (ii) OLAP. (b) Differentiate between snowflake schema and star schema. Support your answer with appropriate

Using DEFAULT You can use the keyword DEFAULT rather than that of the assignment operator to initialize the variables. For e.g. the declaration blood_type CHAR := ’O’; it can b