|
|||||||||
Oracle PL/SQL User's Guide and Reference - Chapter 2
0
Fundamentals of the PL/SQL Language 2-1
2 Fundamentals of the PL/SQL Language The previous chapter provided an overview of PL/SQL. This chapter focuses on the detailed aspects of the language. Like other programming languages, PL/SQL has a character set, reserved words, punctuation, datatypes, and fixed syntax rules. This chapter contains these topics: . Character Sets and Lexical Units . Declarations . PL/SQL Naming Conventions . Scope and Visibility of PL/SQL Identifiers . Assigning Values to Variables . PL/SQL Expressions and Comparisons . Conditional Compilation . Using PL/SQL to Create Web Applications and Server Pages . Summary of PL/SQL Built-In Functions Character Sets and Lexical Units PL/SQL programs are written as lines of text using a specific set of characters: . Upper- and lower-case letters A .. Z and a .. z . Numerals 0 .. 9 . Symbols ( ) + - * / < > = ! ~ ^ ; : . ' @ % , " # $ & _ | { } ? [ ] . Tabs, spaces, and carriage returns PL/SQL keywords are not case-sensitive, so lower-case letters are equivalent to corresponding upper-case letters except within string and character literals. A line of PL/SQL text contains groups of characters known as lexical units: . Delimiters (simple and compound symbols) . Identifiers, which include reserved words . Literals . Comments To improve readability, you can separate lexical units by spaces. In fact, you must separate adjacent identifiers by a space or punctuation. The following line is not allowed because the reserved words END and IF are joined: Character Sets and Lexical Units 2-2 Oracle Database PL/SQL User?s Guide and Reference IF x > y THEN high := x; ENDIF; -- not allowed, must be END IF You cannot embed spaces inside lexical units except for string literals and comments. For example, the following line is not allowed because the compound symbol for assignment (:=) is split: count : = count + 1; -- not allowed, must be := To show structure, you can split lines using carriage returns, and indent lines using spaces or tabs. This formatting makes the first IF statement more readable. IF x>y THEN max:=x;ELSE max:=y;END IF; The following is easier to read: IF x > y THEN max := x; ELSE max := y; END IF; Delimiters A delimiter is a simple or compound symbol that has a special meaning to PL/SQL. For example, you use delimiters to represent arithmetic operations such as addition and subtraction. Table 2?1 contains a list of PL/SQL delimiters. Table 2?1 PL/SQL Delimiters Symbol Meaning + addition operator % attribute indicator ' character string delimiter . component selector / division operator ( expression or list delimiter ) expression or list delimiter : host variable indicator , item separator * multiplication operator " quoted identifier delimiter = relational operator < relational operator > relational operator @ remote access indicator ; statement te... Show full text: 89,013 characters
|
|
||||||||
|
© WP Technology Inc. 2009. User-posted content are subject to its own terms. |
|||||||||