An overview of PL/SQL type characters,identifires,keywords,literals and usage of comments are explained here.
Type Characters PL/SQL is not case sensitive. The lower-case letters are
equivalent to corresponding upper-case letters. There is an exception to this, Characters are grouped together into lexical units. They are the smallest An Identifier is a name for a PL/SQL object. This can be any 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 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 data: Number String Boolean If you want to use the actual value -(There’s no ‘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 ‘LANGUAGE=”ENGLISH”’ ”’String”’ 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. ””” Boolean literlas are TRUE and FALSE
The delimiters are needed to terminate the logical, executable statements. A statement is terminated with a semicolon (;) DECLARE
Single-Line examples follow. — begin processing WHERE empno = emp_id; -- DELETE FROM emp WHERE comm IS NULL; Multi-line bonus := salary * 0.15 You can use multi-line comment delimiters to comment-out whole sections of code, as the following example shows: LOOP
Letters A-Z, a-z
Digits 0-9
Symbols ~ ! @ # $ % & * ( ) _ – + = | [ ] { } : ; ” ‘ < > , . ? /
White space Tab, space, carriage return
within string and character literals, there it is different.
individual language components. In PL/SQL lexical units can be any of the
following.
of the following
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,
1, 11.6, or NULL
`Strig Literal’ or `3-JAN-04′ or NULL
TRUE, FALSE, or NULL
result.)-in String literals, use
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.
eg: 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 comments begin with a double hyphen (–) anywhere on a line and extend to the end of the line.SELECT sal INTO salary FROM emp -- get current salary
Multi-line comments begin with a slash-asterisk (/*), end with an asterisk-slash (*/), and can span multiple lines. Some examples follow:
BEGIN
...
/* 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 */
END; /*
FETCH cur1 INTO emp_rec;
EXIT WHEN cur1%NOTFOUND;
...
END LOOP;
*/
PL/SQL Fundamentals
Published: June 5, 2007 Posted in: Fundamentals
