PL/SQL Fundamentals

      No Comments on PL/SQL Fundamentals
0 Flares Twitter 0 Facebook 0 Google+ 0 LinkedIn 0 Buffer 0 Email -- 0 Flares ×

An overview of PL/SQL type characters,identifires,keywords,literals and usage of comments are explained here.

Type Characters

Letters A-Z, a-z
Digits 0-9
Symbols ~ ! @ # $ % & * ( ) _ – + = | [ ] { } : ; ” ‘ < > , . ? /
White space Tab, space, carriage return

PL/SQL is not case sensitive. The lower-case letters are

equivalent to corresponding upper-case letters. There is an exception to this,
within string and character literals, there it is different.

Characters are grouped together into lexical units. They are the smallest
individual language components. In PL/SQL lexical units can be any of the

  • Identifier

    An Identifier is a name for a PL/SQL object. This can be any
    of the following

    • Constant

    • Variable

    • Exception

    • Procedure

    • Function

    • Package

    • Record

    • PL/SQL table

    • Cursor

    • Reserved word

    An identifier can be up to 30 characters long. It must start
    with a letter and cannot contain spaces. It can include $,_ ad #.Some
    identifiers, called reserved words, have a special
    meaning to PL/SQL and so should not be redefined. For example, the words BEGIN
    and END,

  • Literals

A literal is a value which is not represented by an identifier; it is simply a value. A literal may be composed of one of the following types of


1, 11.6, or NULL

`Strig Literal’ or `3-JAN-04′ or NULL


  • If you want to use the actual value -(There’s no
    result.)-in String literals, use

    ‘There”s no result.’

  • To use a double quoted string literal use like the following,

    ‘”double quoted string”‘

  • To place a single quote at the beginning or end of a literal( eg : LANGUAGE=’ENGLISH’,’string’), put three single quotes together



  • To create a string literal consisting of one single quote(‘), put four single quotes together.


  • To create a string literal consisting of two single quotes together, put six single quotes together.

    Numeric literals can be integers or real numbers.It is allowed to use scientific notation to specify a numeric literal. Use the letter “e” (upper- or lowercase) to raise a number times 10 to the nth power. For example: 10.05E19, 12e-5.

Boolean literlas are TRUE and FALSE

  • Delimiter

The delimiters are needed to terminate the logical, executable statements. A statement is terminated with a semicolon (;)


isAlive BOOLEAN := TRUE;

  • Comments

    Adding comments to your program promotes readability and aids understanding. Generally, you use comments to describe the purpose and use of each code segment. PL/SQL supports two comment styles: single-line and multi-line.
    • Single-Line

      Single-line comments begin with a double hyphen (–) anywhere on a line and extend to the end of the line.

      examples follow.

      — begin processing

      SELECT sal INTO salary FROM emp -- get current salary

      WHERE empno = emp_id;

      -- DELETE FROM emp WHERE comm IS NULL;

    • Multi-line

      Multi-line comments begin with a slash-asterisk (/*), end with an asterisk-slash (*/), and can span multiple lines. Some examples follow:
      /* Compute a 15% bonus for top-rated employees. */
      SELECT sal INTO salary FROM emp -- get current salary
      WHERE empno = emp_id;
      /* The following line computes bonus
      bonus is based on salary */

      bonus := salary * 0.15

      You can use multi-line comment delimiters to comment-out whole sections of code, as the following example shows:


      FETCH cur1 INTO emp_rec;
      END LOOP;

0 Flares Twitter 0 Facebook 0 Google+ 0 LinkedIn 0 Buffer 0 Email -- 0 Flares ×

Leave a Reply

Your email address will not be published. Required fields are marked *

Paged comment generated by AJAX Comment Page