Oracle8i SQLJ Developer's Guide and Reference
Release 8.1.5






Prev  Chap Top Next

Naming Requirements and Restrictions

There are four areas to consider in discussing naming requirements, naming restrictions, and reserved words:

Java Namespace--Local Variable and Class Naming Restrictions

The Java namespace applies to all of your standard Java statements and declarations, including the naming of Java classes and local variables. All standard Java naming restrictions apply, and you should avoid use of Java reserved words.

In addition, SQLJ places minor restrictions on the naming of local variables and classes.


Naming restrictions particular to host variables are discussed in "Restrictions on Host Expressions".  

Local Variable Naming Restrictions

Some of the functionality of the SQLJ translator results in minor restrictions in naming local variables.

The SQLJ translator replaces each executable SQL statement with a statement block, where the executable SQL statement is of the standard syntax:

#sql { SQL operation };  

SQLJ may use temporary variable declarations within a generated statement block. The name of any such temporary variables will include the following prefix:


(There are two underscores at the beginning and one at the end.)

The following declarations are examples of those which might occur in a SQLJ-generated statement block:

int __sJT_index;
Object __sJT_key;
java.sql.PreparedStatement __sJT_stmt;

The string __sJT_ is a reserved prefix for SQLJ-generated variable names. SQLJ programmers must not use this string as a prefix for the following:

Class Naming Restrictions

Be aware of the following minor restrictions in naming classes in SQLJ applications:

SQLJ Namespace

The SQLJ namespace refers to #sql class declarations and the portion of #sql executable statements that is outside the curly braces.


Restrictions that are particular to the naming of iterator columns are discussed in "Using Named Iterators".  

Avoid using the following SQLJ reserved words as class names for declared connection context classes or iterator classes, in with or implements clauses, or in iterator column type declaration lists:

For example, do not have an iterator class or instance called iterator or a connection context class or instance called context.

Note, however, that it is permissible to have a stored function return variable whose name is any of these words.

SQL Namespace

The SQL namespace refers to the portion of a SQLJ executable statement that is inside the curly braces. Normal SQL naming restrictions apply here.

Note, however, that host expressions follow rules of the Java namespace, not the SQL namespace. This applies to the name of a host variable, or everything between the outer parentheses of a host expression.

File Name Requirements and Restrictions

SQLJ source files have the .sqlj file name extension. If the source file declares a public class (maximum of one), then the base name of the file must match the name of this class (case-sensitive). If the source file does not declare a public class, then the file name must still be a legal Java identifier, and it is recommended that the file name match one of the defined classes.

For example, if you define the public class MySource in your source file, then your file name must be MySource.sqlj.


These file naming requirements are according to the Java Language Specification and are not SQLJ-specific. They do not apply in the Oracle8i server, but are still recommended.  



Copyright © 1999 Oracle Corporation.

All Rights Reserved.