Initialize Variables with Default Values in Oracle

Q

How To Initialize Variables with Default Values in Oracle?

✍: FYIcenter.com

A

There are two ways to assign default values to variables at the time of declaration:

  • Using key word DEFAULT - Appending "DEFAULT value" to the end of declaration statements.
  • Using assignment operator - Appending ":= value" to the end of declaration statements.

The script below show you some examples of declaration statements with default values:

PROCEDURE proc_var_1 AS
  domain VARCHAR2(80) := 'fyicenter.com';
  price REAL DEFAULT 999999.99;
  is_for_sale CHAR := 'N';
BEGIN
  -- Executable statements
END;

 

Understanding PL/SQL Language Basics

⇒⇒Oracle Database Tutorials

2016-10-17, 202👍, 0💬