By Steven Feuerstein
With Bill Pribyl
Cover | Table of Contents | Colophon
PROCEDURE maintain_company
(action_in IN VARCHAR2,
id_in IN NUMBER,
name_in IN VARCHAR2 := NULL)
IS
BEGIN
IF action_in = 'DELETE'
THEN
DELETE FROM company WHERE company_id = id_in;
ELSIF action_in = 'INSERT'
THEN
INSERT INTO company (company_id, name)
VALUES (id_in, name_in);
END IF;
END;
PROCEDURE maintain_company
(action_in IN VARCHAR2,
id_in IN NUMBER,
name_in IN VARCHAR2 := NULL)
IS
BEGIN
IF action_in = 'DELETE'
THEN
DELETE FROM company WHERE company_id = id_in;
ELSIF action_in = 'INSERT'
THEN
INSERT INTO company (company_id, name)
VALUES (id_in, name_in);
END IF;
END;
|
Version/Release
|
Characteristics
|
|---|---|
|
Version 1.0
|
First available in SQL*Plus as a batch-processing script. Oracle
Version 6.0 was released at approximately the same time. PL/SQL was
then implemented within SQL*Forms Version 3, the predecessor of
Oracle Forms.
|
|
Release 1.1
|
Available only in the Oracle Developer/2000 Release 1 tools. This
upgrade supports client-side packages and allows client-side programs
to execute stored code transparently.
|
|
Version 2.0
|
Available with Release 7.0 (Oracle Server). Major upgrade to Version
1. Adds support for stored procedures, functions, packages,
programmer-defined records, PL/SQL tables, and many package
extensions, including DBMS_OUTPUT and DBMS_PIPE.
|
|
Release 2.1
|
Available with Release 7.1 of the Oracle Server Version. Supports
programmer-defined subtypes, enables the use of stored functions
inside SQL statements, and offers dynamic SQL with the DBMS_SQL
package. With Version 2.1, you can now execute SQL DDL statements
from within PL/SQL programs.
|
|
Release 2.2
|
my_company company.name%TYPE;
|
Type
|
Characters
|
|---|---|
|
Letters
|
A-Z, a-z
|
|
Digits
|
|
Type
|
Characters
|
|---|---|
|
Letters
|
A-Z, a-z
|
|
Digits
|
0-9
|
|
Symbols
|
~ ! @ # $ % & * ( ) _ - + = | [ ] { } : ; " ' < > , . ? /
|
|
Whitespace
|
Tab, space, carriage return
|
|
Symbol
|
|---|
lots_of_$MONEY$ LOTS_of_$MONEY$ Lots_of_$Money$
lots_of_$MONEY$ |
FirstName |
company_id# |
address_line1 |
'Steven' 'steven'
IF 'Steven' = 'steven'
IF salary < min_salary (1994) THEN salary := salary + salary*.25; END IF;
IF salary < min_salary (1994) THEN salary := salary + salary*.25; END IF;
DECLARE continue_scanning BOOLEAN := TRUE; scan_index NUMBER := 1;
DECLARE continue_scanning BOOLEAN := TRUE; scan_index NUMBER := 1;
IF salary < min_salary (1994) -- Function returns min salary for year. THEN salary := salary + salary*.25; END IF;
PRAGMA <instruction>;
DECLARE no_such_sequence EXCEPTION; PRAGMA EXCEPTION_INIT (no_such_sequence, -2289); BEGIN ... END;
IF to_number(the_value) > 22 THEN IF max_totals = 0 THEN calc_totals; ELSE WHILE more_data LOOP analyze_results; END LOOP; END IF; END IF;
| SELECT | INSERT | UPDATE | DELETE |
|---|---|---|---|
SELECT
FROM
WHERE
AND
OR
GROUP BY
HAVING
AND
OR
ORDER BY
|
INSERT INTO
VALUES
INSERT INTO
SELECT
FROM
WHERE
|
UPDATE SET WHERE |
DELETE FROM WHERE |
IF <expression> END IF; |
IF <expression> ELSE END IF; |
IF <expression> ELSEIF <expression> ELSE END IF; |
| New Line for THEN | Same Line for THEN |
|---|---|
IF <expression> THEN executable_statements; END IF; |
IF <expression> THEN executable_statements END IF; |
IF <expression> THEN executable_statements; ELSE else_executable_statements; END IF; |
IF <expression> THEN executable_statements ELSE else_executable_statements; END IF; |
FUNCTION
company_name (company_id_in IN company.company_id%TYPE) RETURN
VARCHAR2 IS cname company.company_id%TYPE; BEGIN
SELECT name INTO cname FROM company
WHERE company_id = company_id_in;
RETURN cname;
EXCEPTION WHEN NO_DATA_FOUND THEN RETURN NULL; END;
FUNCTION company_name (company_id_in IN company.company_id%TYPE)
RETURN VARCHAR2
IS
cname company.company_id%TYPE;
BEGIN
SELECT name INTO cname FROM company
WHERE company_id = company_id_in;
RETURN cname;
EXCEPTION
WHEN NO_DATA_FOUND
THEN
RETURN NULL;
END;
FUNCTION company_name (company_id_in IN company.company_id%TYPE) RETURN VARCHAR2
PACKAGE rg_select
IS
list_name VARCHAR2(60);
PROCEDURE init_list
(item_name_in IN VARCHAR2,
fill_action_in IN VARCHAR2 := 'IMMEDIATE');
PROCEDURE delete_list;
PROCEDURE clear_list;
END rg_select;
PACKAGE package_name /* || Author: || || Overview: || || Major Modifications (when, who, what) || */ IS ... END package_name;
|
Category
|
Datatype
|
|---|