2.4 The Semicolon Delimiter

Chapter 2
PL/SQL Language Fundamentals
 

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.


2.3 Literals2.5 Comments

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



Oracle PL/SQL Programming
Oracle PL/SQL Programming: Covers Versions Through Oracle Database 11g Release 2 (Animal Guide)
ISBN: 0596514468
EAN: 2147483647
Year: 2004
Pages: 234
Authors: Steven Feuerstein, Bill Pribyl
BUY ON AMAZON

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net