× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.


  • Subject: RE: ProgramCall and ProgramParameter classes
  • From: "Richard Casey" <casey_r@xxxxxxxxxxxxxxxx>
  • Date: Wed, 4 Apr 2001 00:03:51 -0400
  • Importance: Normal

Oops. In the java code below

        CallableStatement stmt = conn.prepareCall("CALL MYLIB/MYPROG(?,?)");

should be

        CallableStatement stmt = conn.prepareCall("CALL MYLIB/MYPROG(?,?,?)");

Sorry about that!

-----Original Message-----
From: owner-java400-l@midrange.com
[mailto:owner-java400-l@midrange.com]On Behalf Of Richard Casey
Sent: Tuesday, April 03, 2001 11:40 PM
To: JAVA400-L@midrange.com
Subject: RE: ProgramCall and ProgramParameter classes


Joe,

Here is an example of calling a stored procedure with two input parameters
and one output parameter (all strings).


        Connection conn = DriverManager.getConnection(...);
        CallableStatement stmt = conn.prepareCall("CALL MYLIB/MYPROG(?,?)");
        // Note - mylib/myprog is the name of the stored procedure, NOT the 
name of
the program to be called
        stmt.setString(1,inputParm1);
        stmt.setString(2,inputParm2);
        stmt.registerOutParameter(3, Types.CHAR);
        stmt.execute();
        String outputParm1 = stmt.getString(3);
        conn.Close();

Of course, you'll need to register your JDBC driver and deal with
exceptions.


Here is an example of creating the corresponding stored procedure on the
AS/400. You can run this statement on the green screen using STRSQL or you
can run it from Operations Navigator.

        create procedure mylib/myprog
        (       in      inparm1 char(10),
                in      inparm2 char(10),
                out     outparm1        char(10))
        language rpg
        external name mylib.myprog
        deterministic
        parameter style general;

The language can be COBOL, RPG, RPGLE, CL, or most of the available
high-level languages. The external name is the name of the program to be
called. The stored procedure and external program do not have to have the
same name. If you need to update the definition of your stored procedure,
you will need to delete it first using the following SQL command.

        drop procedure mylib/myprog;


Hope this helps. I'm in the learning mode here too so if anybody spots a
problem or a better way to do it, just chime in!

Richard Casey

+---
| This is the JAVA/400 Mailing List!
| To submit a new message, send your mail to JAVA400-L@midrange.com.
| To subscribe to this list send email to JAVA400-L-SUB@midrange.com.
| To unsubscribe from this list send email to JAVA400-L-UNSUB@midrange.com.
| Questions should be directed to the list owner: joe@zappie.net
+---

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.