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

HP NonStop SQL/MX Guide to Stored Procedures in Java523727-004
1-1
1 Introduction
This section introduces stored procedures in Java (SPJs) in NonStop SQL/MX and
covers these topics:
What Is an SPJ? on page 1-1
How Do I Use SPJs? on page 1-2
Benefits of SPJs on page 1-4
SPJs in NonStop SQL/MX on page 1-6
The SPJ Environment on page 1-12
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
VST022.vsd
CREATE PROCEDURE samdbcat.sales.lowerprice()
EXTERNAL NAME 'Sales.lowerPrice'
...
;
public static void lowerPrice()
throws SQLException
{
...
}
CALL samdbcat.sales.lowerprice();
3. Invoke the SPJ in NonStop SQL/MX.
2. Register the Java method as an SPJ in NonStop SQL/MX.
1. Write a Java method and compile the Java class.