Reputation: 19892
So I know I can initialize variables in PL/SQL using either of the following:
DEFAULT
keyword:=
assignment operatorFor example:
counter binary_integer DEFAULT 15;
counter binary_integer := 15;
Are these two methods exactly equivalent to the PL/SQL engine, or are there any slight differences?
Upvotes: 2
Views: 149
Reputation: 23578
According to the documentation you can use either:
To specify the initial value, use either the assignment operator (:=) or the keyword DEFAULT, followed by an expression
which means they are equivalent.
Upvotes: 0
Reputation: 17314
Yes they are equivalent.
From Oracle documentation
You can use the keyword DEFAULT instead of the assignment operator to initialize variables. You can also use DEFAULT to initialize subprogram parameters, cursor parameters, and fields in a user-defined record.
Use DEFAULT for variables that have a typical value. Use the assignment operator for variables (such as counters and accumulators) that have no typical value.
Example 2-8 Assigning Default Values to Variables with DEFAULT Keyword
SQL> DECLARE
2 blood_type CHAR DEFAULT 'O'; -- Same as blood_type CHAR := 'O';
3
4 hours_worked INTEGER DEFAULT 40; -- Typical value
5 employee_count INTEGER := 0; -- No typical value
6
7 BEGIN
8 NULL;
9 END;
10 /
PL/SQL procedure successfully completed.
SQL>
Upvotes: 5