I'm newbie in PL/SQL and this question might seem to be 'childish' so I'm sorry in advance, but Google didn't help me at all...
Is there any difference between following procedures?
Procedure p1(a Number DEFAULT 0) Is
Begin
DBMS_OUTPUT.put_line(a);
End;
Procedure p2(a Number := 0) Is
Begin
DBMS_OUTPUT.put_line(a);
End;
I have checked them, so when I call both of them without args the output is 0
, but I'm not sure if there are any side effects.
The assignment statement sets a previously-declared variable or formal OUT or IN OUT parameter to the value of an expression.
Difference between %type and %rowtype in tabular format.If you dont know the datatype of specified column and you require to assign that datatype to the variable then you can use %ROWTYPE.
= is the equality comparison operator, both in PL/SQL and SQL. := is the PL/SQL value assignment operator.
The DEFAULT keyword provides a default value to a column when the Oracle INSERT INTO statement does not provide a specific value. The default value can be literal value, an expression, or a SQL Function, such as SYSDATE.
If you follow Oracle's 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.
DECLARE
blood_type CHAR DEFAULT 'O'; -- Same as blood_type CHAR := 'O';
hours_worked INTEGER DEFAULT 40; -- Typical value
employee_count INTEGER := 0; -- No typical value
BEGIN
NULL;
END;
/
So I guess internally is the same.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With