home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam    

2.4 The Semicolon Delimiter

A PL/SQL program is made up of a series of statements. A statement is terminated with a semicolon ( ; ), not with the physical end of a line. In fact, a single statement is often spread over several lines to make it more readable. The following IF statement takes up four lines and is indented to reinforce the logic behind the statement:

IF salary < min_salary (1994)
THEN
   salary := salary + salary*.25;
END IF;

There are two semicolons in this IF statement. The first semicolon indicates the end of the single executable statement within the IF-END IF construct. The second semicolon terminates the IF statement itself. This same statement could also be placed on a single physical line (if it would fit):

IF salary < min_salary (1994) THEN salary := salary + salary*.25; END IF;

The semicolons are still needed to terminate the logical, executable statements. I suggest that you do not, however, combine the different components of the IF statement on a single line. It is much more difficult to read. I also recommend that you never place more than one executable (or declaration) statement on each line. Compare the following statements:

DECLARE
   continue_scanning BOOLEAN := TRUE;
   scan_index NUMBER := 1;

and:

DECLARE
   continue_scanning BOOLEAN := TRUE; scan_index NUMBER := 1;

In the second example, the two different statements blur into a single stream of text. It is difficult to find the semicolon in the middle of a line.


Previous: 2.3 Literals Oracle PL/SQL Programming, 2nd Edition Next: 2.5 Comments
2.3 Literals Book Index 2.5 Comments

The Oracle Library Navigation

Copyright (c) 2000 O'Reilly & Associates. All rights reserved.

Library Home Oracle PL/SQL Programming, 2nd. Ed. Guide to Oracle 8i Features Oracle Built-in Packages Advanced PL/SQL Programming with Packages Oracle Web Applications Oracle PL/SQL Language Pocket Reference Oracle PL/SQL Built-ins Pocket Reference










??????????????@Mail.ru