Oracle PL/SQL - PL SQL Introduction Literals

Introduction

A literal is a constant value.

For example, 123 is an integer literal and 'abc' is a character literal, but 2+2 is not a literal.

PL/SQL literals include all SQL literals and BOOLEAN literals.

A BOOLEAN literal is the predefined logical value TRUE, FALSE, or NULL.

NULL represents an unknown value.

Character literals

Character literals are case-sensitive. For example, 'A' and 'a' are different.

Whitespace characters in Character literals are significant. For example, 'abc', ' abc', 'abc ', ' abc ', 'a b c' are different.

If you continue a string on the next source line, then the string includes a line-break character. For example, this PL/SQL code:

Demo

SQL>
SQL> BEGIN-- from  w  ww  .ja  v a  2  s .com
  2    DBMS_OUTPUT.PUT_LINE('this is a test
  3  here.');
  4  END;
  5  /
this is a test
here.

PL/SQL procedure successfully completed.

SQL>

To append two line single line character literals, use concatenation operator ( ||).

Demo

SQL>
SQL> BEGIN-- w w w .  jav  a2 s .co  m
  2    DBMS_OUTPUT.PUT_LINE('This string ' ||
  3                         'this is a test.');
  4  END;
  5  /
This string this is a test.

PL/SQL procedure successfully completed.

SQL>

'0' through '9' are not equivalent to the integer literals 0 through 9.

However, because PL/SQL converts them to integers, you can use them in arithmetic expressions.

A character literal with zero characters has the value NULL and is called a null string.

Related Topics