Results 1 to 3 of 3
  1. #1
    Join Date
    Oct 2006

    Unanswered: multiple SQL statements in SQLJ for DB2

    I apologize if this topic has been covered before, but I'm under the gun with a task and need some help pretty quickly.

    I'm new to SQLJ and DB2, but I've written a "Java Stored Procedure" using IBM's development client which builds and loads into DB2 without error. I have multiple calls to #sql but only the first call succeeds. Is there something I'm doing / not doing? I've tried using one context, different contexts, etc. Here is some of the code:

    public static void grm_InsStgComAll ( String subid ) throws SQLException, Exception
    SPContext ctx = null;
    SPContext ctx2 = null;
    ctx = new SPContext( "jdbc:default:connection", false );
    ctx2 = new SPContext( "jdbc:default:connection", false );

    #sql [ctx]
    { my insert to table 1 here };

    #sql [ctx2]
    { my insert to table 2 here };


    When this proc executes, table 1 is populated, but table 2 is not. Any suggestions? Remember, I'm a SQLJ newb so please go easy.

  2. #2
    Join Date
    Aug 2001
    Have you looked at the sqlj samples ?? You should find them under sqllib/samples/java/sqlj

    Visit the new-look IDUG Website , register to gain access to the excellent content.

  3. #3
    Join Date
    Oct 2006
    Thanks for the reply. I've looked at many of the sample files. Most of them do not reference a context when calling #sql and call #sql multiple times in the same method. For instance:

    #sql { INSERT INTO .... };
    instead of
    #sql [myContext] {INSERT INTO ... };

    Does anyone work with IBM's DB2 Development Center in order to create Java stored procedures? I didn't mention that as the platform I'm using, but I'm wondering if the problem exists in the development center as opposed to my code. No matter what I try, it simply will not execute more than one #sql command in the same method. Any suggestions would REALLY be appreciated.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts