473,387 Members | 1,440 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Passing And ARRAY to a Stored Procedure

Hi All;

I am working on project; where I need to call a DB2 stored procedure
(also to be written in the project) which will update/insert some
records in the database. The number of rows to be intserted are decide
at runtime and there is a constraint that the procedure should be
called only once.

So the questino is...
Can we pass a java array or a Collection using JDBC to DB2? If yes how
can we read that array in the DB2 stored procedure? We are using DB2
Connect to connect to DB2 server.
Thanks And Regards,
Viator

Nov 12 '05 #1
8 7513
No, you can't use arrays as parameters to DB2 java routines...what about
using a declared global temp table instead? (Pass the table name into
the java stored proc).

Viator wrote:
Hi All;

I am working on project; where I need to call a DB2 stored procedure
(also to be written in the project) which will update/insert some
records in the database. The number of rows to be intserted are decide
at runtime and there is a constraint that the procedure should be
called only once.

So the questino is...
Can we pass a java array or a Collection using JDBC to DB2? If yes how
can we read that array in the DB2 stored procedure? We are using DB2
Connect to connect to DB2 server.
Thanks And Regards,
Viator

Nov 12 '05 #2
You could pass the array as a varchar and parse it in the proc, but you
cannot pass it as an array or collection.

Pete H

Nov 12 '05 #3
Java procedures in DB2 are not known for their performance. Please
consider using another language (SQL, C) if all this procedure is going
to do is execute some SQL based on somewhat trivial processing.

In my experience, the valid uses for JAVA routines are:

1) Complex operations that are difficult in other languages (accessing
non-text file resources)
2) Anything involving inheritance from a base wrapper class (of course)

Consider that JAVA routines always run in FENCED mode -- this is always
true in V8 even if it is cataloged as NOT FENCED due to issues with
hosting the JVM inside an agent -- and execute dynamic SQL statements.
Both are a significant performance hit.

My experience has been that LANGUAGE JAVA should only be used as a last
resort when no other language will do. JAVA itself is a nice language,
but it's not efficient to use it as an everyday procedure language in DB2.
Viator wrote:
Hi All;

I am working on project; where I need to call a DB2 stored procedure
(also to be written in the project) which will update/insert some
records in the database. The number of rows to be intserted are decide
at runtime and there is a constraint that the procedure should be
called only once.

So the questino is...
Can we pass a java array or a Collection using JDBC to DB2? If yes how
can we read that array in the DB2 stored procedure? We are using DB2
Connect to connect to DB2 server.
Thanks And Regards,
Viator

Nov 12 '05 #4
Another good reason for using java stored procs is back end code
portability maintenance. Of course, there are still issues related to
SQL and jdbc implementation differences between database vendors, but
if your java stored procs are mainly used for driving SQL (not for
processing in jvm) the performance shouldn't be a problem. So we use
java stored procs to support our software product for both DB2 and
Oracle from a single code base.

Regards,
-Eugene

Nov 12 '05 #5
Another good reason for using java stored procs is back end code
portability maintenance. Of course, there are still issues related to
SQL and jdbc implementation differences between database vendors, but
if your java stored procs are mainly used for driving SQL (not for
processing in jvm) the performance shouldn't be a problem. So we use
java stored procs to support our software product for both DB2 and
Oracle from a single code base.

Regards,
-Eugene

Nov 12 '05 #6
Is there an option of using SQL DA for the same. Well we are not
writing procedures in Java but in COBOL. Client is only to be written
in Java. Is there a way to manipulate SQL DA in Java and passing an
ARRAY like structure using that. If it is at all possible how can it be
manipulated in DB2 side using cobol SPs.

Thanks And Regards
Viator

Nov 12 '05 #7
Provided your executing more than just one or two statements, then yes,
that is true. Then again, I'd never recommend ANYONE executing a single
statement in any procedure, regardless of language. DB2 has a statement
cache (as opposed to some DBM that don't) so you're doubling the
overhead -- call + statement -- if all you're executing is one SQL
statement.

Personally, though (and this is just from my experience) JAVA would be
my last recommendation from a purely performance standpoint. SQL or C
will outperform it every time. I honestly do recommend that if you can
write the procedure in another language, than do so.

ef******@gmail.com wrote:
Another good reason for using java stored procs is back end code
portability maintenance. Of course, there are still issues related to
SQL and jdbc implementation differences between database vendors, but
if your java stored procs are mainly used for driving SQL (not for
processing in jvm) the performance shouldn't be a problem. So we use
java stored procs to support our software product for both DB2 and
Oracle from a single code base.

Regards,
-Eugene

Nov 12 '05 #8
No, dari style sps are only supported for C and COBOL.

am*********@gmail.com wrote:
Is there an option of using SQL DA for the same. Well we are not
writing procedures in Java but in COBOL. Client is only to be written
in Java. Is there a way to manipulate SQL DA in Java and passing an
ARRAY like structure using that. If it is at all possible how can it be
manipulated in DB2 side using cobol SPs.

Thanks And Regards
Viator

Nov 12 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: WGW | last post by:
Though I am a novice to MS SQL server (2000 I believe), I can do almost! everything I need. Maybe not efficiently, but usefully. However, I have a problem -- a complex query problem... I can...
1
by: Eugene | last post by:
Hi All, I am having a hard time figuring out how to pass a ("true") java array, like int, from a jdbc application in to a DB2 stored procedure or UDF (can be a java or SQL proc or a table UDF)....
2
by: Bob | last post by:
I'm new to Access projects and SQL server and am not a veteran VB programmer. There's a cry for help! I'm attempting to print the current form on screen by using a command button which the user...
11
by: John Pass | last post by:
Hi, In the attached example, I do understand that the references are not changed if an array is passed by Val. What I do not understand is the result of line 99 (If one can find this by line...
6
by: Paul M | last post by:
Hi All, I'm currently writing a z/OS DB2 Stored Proc in C, using an example from the IBM Stored Procedure guide (SG24-7083-00). The database calls to read and update the database work...
4
by: Ranginald | last post by:
Hi, I'm having trouble passing a parameter from my default.aspx page to my default2.aspx page. I have values from a query in a list box and the goal is to pass the "catID" from default.aspx...
2
by: BobRoyAce | last post by:
I currently have code similar to the following in a few places in my application: cmd.Connection = New SqlClient.SqlConnection(My.Settings.CERMITSConnectionString) cmd.CommandType =...
1
by: =?Utf-8?B?cmFuZHkxMjAw?= | last post by:
Can anyone offer pointers to articles/examples of passing a Ref Cursor ***IN*** to an Oracle stored procedure. I find tons of examples for getting a ref cursor OUT of a stored procedure. I'm using...
0
by: htenay | last post by:
I need to be able to define an array in Java and pass it on to SQL stored procedure. I am new to store proc and found a lot of helpful tutorials on Google but found none that passes parameter of...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.