Environment: DB2 Connect Edition v8.1 fixpak 10 on Solaris 8
Hi all,
I am trying to get a stored procedure working, info from db2diag.log to pin point the error is not useful..
The Java Code:
import java.sql.*;
public class SPUTIL
{
public static void SPTRUNCATE(String databaseName, String tableName)
throws SQLException
{
int errorCode = 0;
String errorLabel = "";
boolean bFlag;
String sql;
PreparedStatement stmt = null;
try
{
Connection con = DriverManager.getConnection("jdbc:default:connecti on");
sql = "IMPORT FROM /dev/null OF DEL REPLACE INTO " + "'" + databaseName + "'.'"
+ tableName + "'";
stmt = con.prepareStatement( sql );
bFlag = stmt.execute();
}
catch ( SQLException sqle)
{
errorCode = sqle.getErrorCode();
throw new SQLException ( errorCode + " : " + errorLabel + " FAILED" );
}
}
}
I Compiled the java code to class file and put it in <instance>/sqllib/function folder..
I ran the following script
CREATE PROCEDURE DPS.SPTRUNCATE
(IN DBNAME VARCHAR(8) , IN TBLNAME VARCHAR(8))
SPECIFIC DPS.SPTRUNCATE
DYNAMIC RESULT SETS 0
NOT DETERMINISTIC
LANGUAGE JAVA
PARAMETER STYLE JAVA
EXTERNAL NAME 'SPUTIL.SPTRUNCATE'
FENCED
THREADSAFE
The script ran successfully, but when i call the procedure
CALL SPTRUNCATE('TSTDB','TAB1')
SQL4302N Procedure or user-defined function "DPS.SPTRUNCATE", specific name "SPTRUNCATE" aborted with an exception "-104 : FAILED". SQLSTATE=38501
SQL4302N Procedure or user-defined function "DPS.SPTRUNCATE", specific name "SPTRUNCATE" aborted with an exception "-104 : FAILED ".
Explanation:
The procedure or user-defined function aborted with an exception.
The administration notification log contains a stack traceback
for the aborted routine.
User Response:
Debug the routine to eliminate the exception.
sqlcode : -4302
sqlstate : 38501
Any pointers?
Thanks in Advance,
Newbie