Neoview Guide to Stored Procedures in Java (R2.3, R2.4)
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 DB Admin, and then enter or select these values
in the Create Procedure Wizard of DB Admin. For instructions, see “Uploading SPJ JAR Files to
the Neoview Platform” (page 35) and “Creating SPJs” (page 43).
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:
104 Sample SPJs