

ss
Oracle Tips by Burleson 
Variable Declaration and
Conversion
In the previous examples a variable v_line
was defined. All variables are defined in the declaration section of
the block. Variables are defined in the form:
variableName
datatype := defaultvalue;
Below are examples of variables. Variables can be
defined as any valid datatype
to include user defined datatypes
and records.
declare
v_str1 varchar2(80);
v_str2 varchar2(30) := ‘Hello World’;
d_today date;
n_sales number;
n_order number(8);
begin
A constant
is defined the same way a variable
is with the key word constant.
c_standard
constant number := 90;
Notice that a constant must be
assigned a value and the above statement does four things:

Names the variable
c_standard

Defines
c_standard as a constant

Defines
c_standard as a numeric
datatype

Assigns a
value of 90 to c_standard
With PL/SQL
constants, note that a constant value
can’t be changed unless it is redefined in a subsequent block.
In the examples above our two variables are
defined as numbers, and we are now ready to see how to include the
precision and scale for a number. As in SQL, PL/SQL supports
mathematical operations and has a large library of mathematical
functions, covering everything from advanced multivariate statistics
to Newtonian Calculus
. PL/SQL also supports singlerow
functions to convert numbers to characters and characters to numbers.
The above book excerpt is from:
Easy Oracle PL/SQL Programming
Get Started
Fast with Working PL/SQL Code Examples
ISBN 0975913573
John Garmany
http://www.rampantbooks.com/book_2005_1_easy_plsql.htm
