By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,514 Members | 1,683 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,514 IT Pros & Developers. It's quick & easy.

inline SQL PL over JDBC

P: n/a
Hi there,

Is it possible to use inline SQL PL over JDBC? If so, which statement
type is required and what syntax does the inline SQL PL take? A
CallableStatement, for example, need to be enclosed within curly
braces: eg:

{CALL some_procedure()}

Cheers

Michael

Feb 20 '07 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Kenevel wrote:
Hi there,

Is it possible to use inline SQL PL over JDBC? If so, which statement
type is required and what syntax does the inline SQL PL take? A
CallableStatement, for example, need to be enclosed within curly
braces: eg:
Not clear I understand your question...
Ar eyou asking whether you can submit a BEGIN ATOMIC ... END from JDBC?
The answer to that AFAIk is yes. Use the same API you use for e.g. UPDATE.

Cheers
Serge
--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab
Feb 21 '07 #2

P: n/a
Kenevel wrote:
Hi there,

Is it possible to use inline SQL PL over JDBC? If so, which statement
type is required and what syntax does the inline SQL PL take? A
CallableStatement, for example, need to be enclosed within curly
braces: eg:

{CALL some_procedure()}
That is not correct. You can call a stored procedure through JDBC simply
this way:

CALL some_procedure(...)

Have a look at the samples, specifically
sqllib/samples/java/jdbc/SpClient.java.

--
Knut Stolze
DB2 z/OS Utilities Development
IBM Germany
Feb 21 '07 #3

P: n/a
On 21 Feb, 12:49, Serge Rielau <srie...@ca.ibm.comwrote:
>
Not clear I understand your question...
Are you asking whether you can submit a BEGIN ATOMIC ... END from JDBC?
The answer to that AFAIk is yes. Use the same API you use for e.g. UPDATE.
Hi Serge,

Yes: I am asking whether I can submit a BEGIN ATOMIC ... END over
JDBC. There are advantages from an application-packaging point-of-view
if you can keep this sort of logic within the Java application itself,
rather than installing the same logic in the DB as a stored procedure
or function - both from a deployment and a rollback perspective.

My problem is that the simple examples I've tried have invariably all
complained about the syntax - so I wondered whether anyone knew the
exact Java statement type (eg: Statement, CallableStatement,
PreparedStatement) to use, and also the associated syntax (hence the
quick example in my first post of how the syntax for a
CallableStatement varies from a Statement or PreparedStatement).

Cheers

Michael

Feb 22 '07 #4

P: n/a
I may be dumb, but I know people ... ;-)
Try this:

Statement stmt = con.createStatement();
stmt.execute( "begin atomic" +
" insert into t1 values (1);" +
" insert into t1 values (2);" +
"end" );

PreparedStatement pstmt = con.prepareStatement(
"begin atomic" +
" insert into t1 values (?);" +
" insert into t1 values (?);" +
"end" );

pstmt.setInt( 1, 3 );
pstmt.setInt( 2, 4 );
pstmt.execute();

Cheers
Serge

--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab
Feb 22 '07 #5

P: n/a
Kenevel wrote:
My problem is that the simple examples I've tried have invariably all
complained about the syntax - so I wondered whether anyone knew the
exact Java statement type (eg: Statement, CallableStatement,
PreparedStatement) to use, and also the associated syntax (hence the
quick example in my first post of how the syntax for a
CallableStatement varies from a Statement or PreparedStatement).
What exactly are those statements and what are the errors you got from DB2?
As Serge said, compound statements are regular SQL statements and you can
execute them as usual through JDBC. So I would suspect a problem with your
application.

--
Knut Stolze
DB2 z/OS Utilities Development
IBM Germany
Feb 22 '07 #6

This discussion thread is closed

Replies have been disabled for this discussion.