PL/SQL Literals

PL/SQL Literals

PL/SQL Literals – A literal is a numeric value or a character string used to represent itself. So, literals can be classified into two types:
  1. Numeric literals
  2. Non-numeric literals( string literals)

1.PL/SQL Numeric literals:

These can be either integers or floating point numbers. If a float is being represented, then the integer part must be separated from the float part by the period (.).

Integers are 26, 27, 456, -58 etc.
Floats are 6.35, 26E-05, 0.1, +17.2 etc.

2.PL/SQL Non numeric literals:

These are represented by one or more legal characters and must be enclosed within single quotes.
Ex:    ‘Hello world’

‘ * ‘
We can represent single quote character itself in a non-numeric literal by writing it twice.
Ex: “Don’t go without saving the program”
PL/SQL will also have literals, which are called as logical (Boolean) literals. These are predetermined constants. The values it can take are TRUE, FALSE, and NULL.

PL/SQL Comments

  • A comment line begins with a double hyphen (-). In this case the entire line will be treated as a comment.
Ex: this section performs salary updating.
  • The comment line begins with a slash following by an asterisk (/*) till the occurrence of an asterisk followed by a slash (*/). In this case comment lines can be extended to more than one line.
Example-1:   /* this is only for user purpose which calculates the total salary temporarily and stores the value in temp_sal */ .
Example-2: /* this takes rows from /* table EMPLOYEE */ and put on another table */
In the above comment, there is a comment within another comment line, this is not allowed in PL/SQL.

Leave a Reply

Your email address will not be published.