If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > multiple SQL statements in SQLJ for DB2

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-04-06, 18:36
phinole phinole is offline
Registered User
 
Join Date: Oct 2006
Posts: 2
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;
try
{
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.
Reply With Quote
  #2 (permalink)  
Old 10-04-06, 20:53
sathyaram_s sathyaram_s is offline
Super Moderator
 
Join Date: Aug 2001
Location: UK
Posts: 4,534
Have you looked at the sqlj samples ?? You should find them under sqllib/samples/java/sqlj

Sathyaram
__________________
Visit the new-look IDUG Website , register to gain access to the excellent content.
Reply With Quote
  #3 (permalink)  
Old 10-05-06, 12:15
phinole phinole is offline
Registered User
 
Join Date: Oct 2006
Posts: 2
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.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On