SQL/MX Guide to Stored Procedures in Java (G06.24+, H06.03+)

Writing SPJ Methods
HP NonStop SQL/MX Guide to Stored Procedures in Java523727-004
3-4
Using the main() Method
support SPJs and for cross-references to the appropriate manuals for type mappings
between NonStop SQL/MX and the API.
Stored Procedure Result Sets
Currently, NonStop SQL/MX does not support SPJs that return stored procedure result
sets. A stored procedure result set is a cursor that is left open when the SPJ method
returns control to the database server and from which the invoking application can
retrieve multiple rows of data.
Using the main() Method
You can use the main() method of a Java class file as an SPJ method. The main()
method is different from other Java methods because it accepts input values in an
array of java.lang.String objects and does not return any values in its array
parameter.
For example, you can register this main() method as an SPJ:
public static void main (java.lang.String [] args) {
...
}
When you register a main() method as an SPJ, the CREATE PROCEDURE
statement can contain zero or more SQL parameters, even though the underlying
main() method has only one array parameter. All the SQL parameters of the SPJ
must have the character string data type, CHAR or VARCHAR, and be declared with
the IN mode.
If you specify the optional Java signature in the EXTERNAL NAME clause of the
CREATE PROCEDURE statement, the signature must be (java.lang.String
[]). For more information about creating an SPJ, see the Using the CREATE
PROCEDURE Statement on page 4-2.
Null Input and Output
You can pass a null value as input to or output from an SPJ method, provided that the
Java data type of the parameter supports nulls. Java primitive data types do not
support nulls. However, Java wrapper classes that correspond to primitive data types
do support nulls. If a null is input or output for a parameter that does not support nulls,
NonStop SQL/MX raises an error condition.
To anticipate null input or output for your SPJ, use Java wrapper classes instead of
primitive data types in the method signature.
For example, this Java method uses a Java primitive data type in its signature where
no null values are expected:
public static void employeeJob(int empNum,
Integer[] jobCode)