type-attribute

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

type-attribute [2015/09/23 20:27] (current)
Line 1: Line 1:
 +====== %TYPE Attribute ======
 +
 +%TYPE attribute lets you declare a variable that has the same data type as the specified referenced column.
 +
 +**Syntax**:
 +
 +<code language=sql>​
 +var_name [schema.]table.column_name%TYPE
 +</​code>​
 +
 +  * If //​table.column_name//​ cannot be found, the data type is derived from the first assignment expression.
 +
 +**Example:​**
 +
 +<code language=sql>​
 +DECLARE ​
 +  i orders.item%TYPE;​
 +BEGIN
 +  SELECT item INTO i FROM orders LIMIT 1;
 +  DBMS_OUTPUT.PUT_LINE('​Item:​ ' || i);
 +END;
 +</​code>​
 +
 +**Compatibility:​** Oracle
 +
 +**Version:​** HPL/SQL 0.3.13
 +