The SQL offline parser in SQLJ translator, simply called
offline
parser, performs syntax checking for Oracle SQL and PL/SQL statements
during SQLJ semantic analysis. The Oracle semantic checker can also perform
SQL syntax checking using an online parser. The online parser connects
to a RDBMS and delegates the parsing task to the PL/SQL engine in the server.
The offline parser, on the contrary, does not require a connection to RDBMS.
In addition, the offline parser can check DDL statements, which are not
checked by the online parser. However, the online parser performs stronger
checking than the offline parser. Semantic errors such as missing columns
can only be detected online. Thus, the offline parser does not eliminate
the necessity of online parsing and other online tasks.
By default, the Oracle semantic checker always performs offline parsing before online parsing. However, user can disable the offline parser, the online parser, or both through the -parse option in the SQLJ command line translator. Below is the help information for the -parse option given by the SQLJ command line translator.
name: parseLike the online parser, the offline parser gives warnings when syntax errors are detected to allow the translation process to continue.
type: online-only, offline-only, both, none, or name of a Java class
value: online-only
description: Setting for SQL syntax parsing: either only through a database connection (online-only), or only through a syntax parser (offline-only), or through both, or none of these mechanisms. Alternatively, one may specify the Java classname of a SQL parser.
set from: default
#sql { DELETE FROM SELECT FROM SALES };Each SQL statement contains a syntax error. The first SQL statement contains extra tokens "SELECT FROM". The second statement contains an invalid identifier "984j".
#sql { INSERT INTO SALES VALUES( :itemID,.234k, :itemName,:dateSold,:totalCost,:salesRepID,984j, :salesRepName) };
The command
% sqlj -parse=both -user=scott/tiger -warn=nonulls,noprecision ParseDemo.sqljinvokes both the offline parser and the online parser. From the message below, which is output by the command above, we can see that each errors are reported twice, once by the offline parser and then also by the online parser.
*********Begin ParseDemo *******
ParseDemo.sqlj:90.5-90.53: Warning: Invalid PL/SQL syntax at:
BEGIN DELETE FROM SELECT FROM SALES; END
^^
Encountered ";" :
Was expecting one of:
"FROM" ...
"INTO" ...
"BULK" ...
"," ...ParseDemo.sqlj:90.5-90.53: Warning: Database issued an error: PL/SQL: ORA-00903: invalid table name
BEGIN DELETE FROM SELECT FROM SALES; END ;
^^^^^^ParseDemo.sqlj:117.5-118.44: Warning: Invalid SQL syntax at:
INSERT INTO SALES VALUES( ... , ... , ... , ... ,
... ,984j, ... )
^^
Encountered "j" :
Was expecting one of:
"AND" ...
"BETWEEN" ...
"IN" ...
"IS" ...
"LIKE" ...
"NOT" ...
"OR" ...
"AT" ...
"MOD" ...
"RANGE" ...
<CONCAT_OP_> ...
".." ...
<NOTEQL_> ...
<GTEQL_> ...
<LTEQ_> ...
"," ...
"(" ...
")" ...
"=" ...
"<" ...
">" ...
"+" ...
"-" ...
"*" ...
"/" ...
"&" ...
<ASSOC_OP_> ...
"REM" ...
"EXP" ...
"BOX" ...
"CAT" ...ParseDemo.sqlj:117.5-118.44: Warning: Database issued an error: PL/SQL: ORA-00917: missing comma
INSERT INTO SALES VALUES( ... , ... , ... , ... ,
... ,984j, ... ) ;
^
Total 4 warnings.*******End of ParseDemo.sqlj *****