background image
<< Using Variables and Constants | Editing an Existing Function >>
<< Using Variables and Constants | Editing an Existing Function >>

Declaring Variables and Constants

Using Variables and Constants
4-16 Oracle Database 2 Day Developer's Guide
Using Variables and Constants
Variables and constants can have any SQL or PL/SQL data type, and are declared in
the declaration block of a subprogram. By default, any variable that is declared has a
value of
NULL
. When defining a constant, you must use the
CONSTANT
clause, and
assign a value immediately.
Using Comments
In PL/SQL, in-line comments start with a double hyphen,
--
, and extend to the end of
the line. Multi-line comments must start with a slash and asterisk,
/*
, and terminate
with an asterisk and a slash,
*/
.
Using Identifiers
Identifiers name PL/SQL program units such as constants, variables, and
subprograms. All identifiers must have at most 30 characters, and must start with a
letter that is followed by any combination of letters, numerals, and the signs '
$
', '
_
',
and '
#
'. Other characters cannot be used in identifiers.
Note that because PL/SQL is not case-sensitive except in managing string and
character literals, you can use uppercase and lowercase letters interchangeably. This
means that an identifier
last_name
is equivalent to
LAST_NAME
. Declaring the
second identifier generates an error.
You should use meaningful names for your variables and constants, and use a good
naming convention. For example, you could start each constant name with '
cons_
'.
Also, remember not to use reserved words as identifiers.
Declaring Variables and Constants
You will update the new function of the
emp_eval
package,
calculate_score
,
which calculates the final score for the employee evaluation by combing all weighted
scores in different categories.
See Also:
Oracle Database PL/SQL Language Reference for general information
on PL/SQL data types
Oracle Database PL/SQL Language Reference for information about
the
PLS_INTEGER
See Also:
Oracle Database PL/SQL Language Reference
See Also:
Oracle Database PL/SQL Language Reference
See Also:
Oracle Database PL/SQL Language Reference for information on the
scope and visibility of identifiers
Oracle Database PL/SQL Language Reference for information how to
collect data on identifiers
Oracle Database PL/SQL Language Reference for information on how
PL/SQL resolves identifier names