Oracle PL/SQL - PL SQL Introduction Constant Declarations

Introduction

A constant declaration has two more elements:

  • the keyword CONSTANT and
  • the initial value of the constant.

The following code declares three constants with scalar data types.

Demo

SQL>
SQL> DECLARE-- from w w w.  j ava 2 s.  c o m
  2   credit_limit     CONSTANT REAL    := 5000.00;  -- SQL data type
  3   max_days_in_year CONSTANT INTEGER := 366;      -- SQL data type
  4   my_boolean       CONSTANT BOOLEAN := FALSE;    -- PL/SQL-only data type
  5  BEGIN
  6   DBMS_OUTPUT.PUT_LINE(credit_limit);
  7   DBMS_OUTPUT.PUT_LINE(max_days_in_year);
  8   DBMS_OUTPUT.PUT_LINE(my_boolean);
  9   NULL;
 10  END;
 11  /
 DBMS_OUTPUT.PUT_LINE(my_boolean);
 *
ERROR at line 8:
ORA-06550: line 8, column 2:
PLS-00306: wrong number or types of arguments in
call to 'PUT_LINE'
ORA-06550: line 8, column 2:
PL/SQL: Statement ignored


SQL>

You cannot output boolean type using DBMS_OUTPUT.PUT_LINE.

Related Topics