This is a very simple DB2 SQLJ stored procedure. The problem is that it
seems to run fine but returns NOTHING. I mean..as if nothing has
happened..not resultset is returned. I am passing value 'D11' to :workdept
and I have checked in the table that 6 rows should have returned. Any
ideas why no resultset is being returned.
import java.sql.*;
import sqlj.runtime.*;
import sqlj.runtime.ref.*;
import java.io.*; // Input/Output classes
#sql iterator Sproc3_Iterator(String lname,String fname);
#sql context SpContext;
public class sproc3
{
public static void sproc3mtd ( String workdept,
ResultSet[] rs1 ) throws Exception
{
char error = 'n';
SpContext ctx = new SpContext( "jdbc:default:connection", false
);
Sproc3_Iterator sproc3_iterator = null;
// Get connection to the database
try
{
Connection con =
DriverManager.getConnection("jdbc:default:connection");
#sql [ctx] sproc3_iterator = {SELECT FIRSTNME, LASTNAME FROM
db2admin.EMPLOYEE WHERE WORKDEPT = :workdept};
rs1[0] = sproc3_iterator.getResultSet();
ctx.close();
} catch (SQLException sqlexcp)
{
sqlexcp.getMessage();
error = 'y';
}
}
}
The stored procedure definition is:
CREATE PROCEDURE SP3 (IN in1 CHAR(6))
LANGUAGE JAVA
PARAMETER STYLE JAVA
DYNAMIC RESULT SETS 1
FENCED THREADSAFE
EXTERNAL NAME
'sproc3.sproc3mtd';
TIA
Raquel.
Raquel - 25 Jun 2004 12:42 GMT
Please don't bother...it is not returning anything because the table being
referred to in the stored procedure (db2admin.EMPLOYEE) does not exist. It
is actually db2adm.EMPLOYEE. This solved the problem.
Thanks.
Raquel.