Neoview Guide to Stored Procedures in Java (R2.3, R2.4)

EMPLOYEEJOB Procedure
The EMPLOYEEJOB procedure accepts an employee number and returns a job code or null value
to an output parameter.
Java Method: employeeJob()
Example A-10 employeeJob() Method
public static void employeeJob(int empNum,
java.lang.Integer[] jobCode)
throws SQLException
{
Connection conn = DriverManager.getConnection("jdbc:default:connection");
PreparedStatement getJobcode =
conn.prepareStatement("SELECT jobcode " +
"FROM persnl.employee " +
"WHERE empnum = ?");
getJobcode.setInt(1, empNum);
ResultSet rs = getJobcode.executeQuery();
rs.next();
int num = rs.getInt(1);
if (rs.wasNull())
jobCode[0] = null;
else
jobCode[0] = new Integer(num);
rs.close();
conn.close();
}
Creating the Procedure: EMPLOYEEJOB
To create this procedure in the PERSNL schema, upload the Payroll.jar file to the Neoview
platform, navigate to the PERSNL 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).
employeejobName:
Payroll.jar > Payroll > employeeJobCode:
First SQL parameter:
Name: empnum
Direction: IN
SQL Data Type: INTEGER
Java Data Type: int
Second SQL parameter:
Name: jobcode
Direction: OUT
SQL Data Type: INTEGER
Java Data Type: java.lang.Integer[]
Parameters:
Dynamic result sets: 0
Accesses Database: selected
Attributes:
Calling the Procedure: EMPLOYEEJOB
To invoke the EMPLOYEEJOB procedure in NCI:
SQL>call persnl.employeejob(337, ?);
Procedures in the PERSNL Schema 95