
Syntactic Checking
By checking the syntax of embedded SQL statements and PL/SQL blocks, the Pro*Ada Precompiler helps you quickly find and fix coding mistakes. This appendix shows you how to use the SQLCHECK option to control the type and extent of checking. The discussion includes the following topics:
Rules of Syntax
Rules of syntax specify how language elements are sequenced to form valid statements. Thus, syntactic checking verifies that keywords, object names, operators, delimiters, and so on are placed correctly in your SQL statement. For example, the following embedded SQL statements contain syntax errors:
EXEC SQL DELETE FROM EMP WHER DEPTNO = 20;
-- misspelled keyword, WHERE
EXEC SQL INSERT INTO EMP COMM, SAL VALUES (NULL, 1500);
-- missing parentheses around column names, COMM and SAL
The rules of SQL syntax are defined in the Oracle7 Server SQL Language Reference Manual.
Controlling the Type and Extent of Checking
You control the type and extent of checking by specifying the SQLCHECK option on the command line. With SQLCHECK, the type of checking can be syntactic or none. The extent of checking can include the following:
- Data Definition Language statements (such as CREATE
and GRANT)
- Data Manipulation Language statements (such as SELECT
and INSERT)
However, SQLCHECK cannot check dynamic SQL statements because they are not fully defined until run time.
You can specify the following values for SQLCHECK: SYNTAX or NONE. The default value is SYNTAX. The use of SQLCHECK does not affect the normal syntax checking done on data control, cursor control, and dynamic SQL statements.
Specifying SQLCHECK=SYNTAX
When you specify SQLCHECK=SYNTAX, the precompiler checks the syntax of
- data manipulation statements
- data definition statements
No semantic check is done, and the following restrictions apply:
- No connection to Oracle is attempted, and USERID becomes
an invalid option. If you specify USERID, a warning message
is issued.
- DECLARE TABLE statements are ignored; they serve only as documentation.
- PL/SQL blocks are not allowed. If the precompiler finds a PL/SQL block, an error message is issued.
When checking data manipulation statements, the precompiler uses Oracle Version 6 syntax and semantic rules. These rules are upwardly compatible with those of Version 5, so specify SQLCHECK=SYNTAX when migrating your precompiled programs.
Specifying SQLCHECK=NONE
When you specify SQLCHECK=NONE (the default), a minimal syntactic check is done and the following restrictions apply:
- No connection to Oracle is attempted, and USERID becomes
an invalid option. If you specify USERID, a warning message
is issued.
- DECLARE TABLE statements are ignored; they serve only
as documentation.
- PL/SQL blocks are not allowed. If the precompiler finds a PL/SQL block, an error message is issued.
Specify SQLCHECK=NONE only if
- your program references tables not yet created and is missing DECLARE TABLE statements for them
- stricter datatype checking is undesirable