Call AS/400 DB2 Stored Procedure?

Call AS/400 DB2 Stored Procedure?

Post by Bill Kierstea » Fri, 28 Jul 2000 04:00:00



Need help calling a stored procedure in a AS/400 DB2 database.

Following an example in a Java Book, I have come up with the following:

The stored procedure is called NEXTID and takes 4 INOUT arguments.

NAME             DATATYPE
TABLENAME        CHAR(10)
CUSTOMERID       DECIMAL(8,0)
NEXTID           DECIMAL(11,0)
VALIDFLAG        CHAR(1)

        NextId ni = new NextId( );
        Integer customer = new Integer( 0 );
        Integer nextId = new Integer( 0 );
        String valid = new String( "" );

        try
        {

            as400Connection =
servletPersistenceSessionFactory.getAS400Connection( );
            statement = as400Connection.createStatement( );

            CallableStatement cs = as400Connection.prepareCall( "{call "
+ DBConnection.custFilesLibrary + ".NEXTID(?, ?, ?, ?)}" );

            cs.registerOutParameter( 1, Types.CHAR );
            cs.registerOutParameter( 2, Types.DECIMAL );
            cs.registerOutParameter( 3, Types.DECIMAL );
            cs.registerOutParameter( 4, Types.CHAR );

            cs.setObject( 1, tableName, Types.CHAR );
            cs.setObject( 2, customer, Types.DECIMAL );
            cs.setObject( 3, nextId, Types.DECIMAL );
            cs.setObject( 4, valid, Types.CHAR );

            cs.executeQuery( );
            // have also tried executeUpdate( );

The execute statement fires a SQLException that the SQLDA is not valid.

sqle.getSQLState() returns 07002

Any ideas?

Thank you

 
 
 

1. calling of a simple stored procedure with a driver HIT JDBC/400 v2.5

Hallo,
We want to test the driver HIT JDBC/400 v2.5 for a connection to a
remote AS/400 over a VPN-WAN.
Now we are looking for sample files for calling of a simple stored
procedure.
Where can we find such kind of sample files?
Do you know a good information portal. (FAQ)
Thanks.
Hans-Joachim Gutmann

2. Update statement?

3. DB2/400 Stored Procedure Output Parm with .NET OLEDB

4. Access Ingres DB from MacIntosh

5. trigger to call AS/400 stored procedure

6. DB2/400 Stored Procedure w/ADO--return result set

7. Can Crystal Report use DB2/400 Stored Procedure ?

8. DB2 STORE PROCEDURES IN AS/400 AND SERVLET

9. SP call to DB2/400 linked server

10. Call Pgm/Run commands on DB2/400 databases

11. Calling Stored Procedure that calls Stored Procedure in ASP