473,729 Members | 2,335 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 7571
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*********@gma il.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
16945
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 create a parameter query in a stored procedure, but how do I use the result set of a parameter query in a select query (in the same or another sp)? In short, if a select query contains a result table that is generated as a parameter query, how do I...
1
4740
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). Having the application to write the array to a DB2 global temp table, or passing it in any surrogate form like delimited string (or a byte stream) of elements, are not possible alternatives. Is that implementable at all with DB2 jdbc? (I am using...
2
5276
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 clicks once they have selected the desired record. The button calls a report which uses a stored procedure as its record source. The SP has 2 input parameters, one of which is a datetime data type. In the input parameters data field of the...
11
8127
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 number) which is the last line of the following sub routine: ' procedure modifies elements of array and assigns ' new reference (note ByVal) Sub FirstDouble(ByVal array As Integer()) Dim i As Integer
6
2160
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 fine...however, I can't seem to figure out how to pass parms to the C Program. The compile, bind, and run using DB2BATCH all work fine, however, when I attempt to access any values passed into the program, they're not present. Here's part of the JCL...
4
2758
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 to a stored procedure on the details2.aspx page. I can successfully pass the values from the listbox control to a
2
1826
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 = CommandType.StoredProcedure cmd.CommandText = "usp_Users_Insert" cmd.Parameters.AddRange(SQLParam) cmd.ExecuteNonQuery()
1
7159
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 the Microsoft.Practices.EnterpriseLibrary.Data.DatabaseFactory, NOT the ODT.NET library (please don't ask why). Thanks, Randy
0
2217
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 type list, process and return result. My question is: I like to be able to pass input parameter of type list into stored procedure and pars the list, process it and return result set. It is an SQL stored procedure (in DB2) that is called with in...
0
8917
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8761
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9281
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9142
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8148
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6722
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4525
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4795
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2680
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.