SQL/MX 3.2.1 Guide to Stored Procedures in Java (H06.26+, J06.15+)

1 Introduction
This section introduces stored procedures in Java (SPJs) in NonStop SQL/MX and covers these
topics:
What Is an SPJ? (page 17)
How Do I Use SPJs? (page 18)
Benefits of SPJs (page 19)
SPJs in NonStop SQL/MX (page 21)
The SPJ Environment (page 24)
What Is an SPJ?
A stored procedure is a type of user-defined routine (UDR) that operates within a database server.
The database server contains the metadata of stored procedures and controls their execution. A
stored procedure, which can perform SQL operations on a database, is invoked by a client
application using an SQL CALL statement. Unlike a user-defined function, a stored procedure does
not return a value directly to its caller. Instead, a stored procedure returns each output value to a
host variable or dynamic parameter in its parameter list.
NonStop SQL/MX supports stored procedures written in the Java programming language. A stored
procedure in Java (SPJ) is a Java method contained in a Java class, registered in SQL/MX system
metadata tables, and invoked by NonStop SQL/MX when an application issues a CALL statement:
The body of a stored procedure consists of a public, static Java method that returns void.
These methods, called SPJ methods, are contained in class files in the HP NonStop Open System
Services (OSS) file system, and a group of class files or packages can be stored in a Java archive
(JAR) file. The SQL statement, CREATE PROCEDURE, registers a Java method as a stored procedure
in the database by storing its name, parameter types, location, and other metadata in SQL/MX
system metadata tables. An SPJ method must be registered in NonStop SQL/MX before an SQL/MX
application can call it. For more information about how SPJs operate in NonStop SQL/MX, see
SPJs in NonStop SQL/MX (page 21).
NOTE: The SQL/MX implementation of SPJs complies mostly, unless otherwise specified, with
SQL/JRT (Java Routines and Types), which extends the ANSI SQL/Foundation standard.
What Is an SPJ? 17