Neoview Guide to Stored Procedures in Java (R2.5)

SUPPLYNUMBERS Procedure
The SUPPLYNUMBERS procedure returns the average, minimum, and maximum quantities of
available parts in inventory to separate output parameters.
Java Method: supplyQuantities()
Example A-15 supplyQuantities() Method
public static void supplyQuantities(int[] avgQty,
int[] minQty,
int[] maxQty)
throws SQLException
{
Connection conn = DriverManager.getConnection("jdbc:default:connection");
PreparedStatement getQty =
conn.prepareStatement("SELECT AVG(qty_on_hand), " +
" MIN(qty_on_hand), " +
" MAX(qty_on_hand) " +
"FROM invent.partloc");
ResultSet rs = getQty.executeQuery();
rs.next();
avgQty[0] = rs.getInt(1);
minQty[0] = rs.getInt(2);
maxQty[0] = rs.getInt(3);
rs.close();
conn.close();
}
Creating the Procedure: SUPPLYNUMBERS
To create this procedure in the INVENT schema, upload the Inventory.jar file to the Neoview
platform, navigate to the INVENT schema in HPDM, and then enter or select these values in the
Create Procedure dialog box of HPDM. For more information, see the HP Database Manager
(HPDM) User Guide.
supplynumbersName:
Inventory.jar > Inventory > supplyQuantitiesCode:
First SQL parameter:
Name: avrg
Direction: OUT
SQL Data Type: INTEGER
Java Data Type: int[]
Second SQL parameter:
Name: minm
Direction: OUT
SQL Data Type: INTEGER
Java Data Type: int[]
Third SQL parameter:
Name: maxm
Direction: OUT
SQL Data Type: INTEGER
Java Data Type: int[]
Parameters:
Dynamic result sets: 0
Accesses Database: selected
Attributes:
Procedures in the INVENT Schema 97