Unix Technical Forum

Passing a java array in to a DB2 stored procedure

This is a discussion on Passing a java array in to a DB2 stored procedure within the DB2 forums, part of the Database Server Software category; --> Hi All, I am having a hard time figuring out how to pass a ("true") java array, like int[], ...


Go Back   Unix Technical Forum > Database Server Software > DB2

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-26-2008, 06:01 PM
Eugene
 
Posts: n/a
Default Passing a java array in to a DB2 stored procedure

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 DB2 UDB 8.1.4 for
Linux)

Thanks,
-Eugene
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-26-2008, 06:02 PM
Serge Rielau
 
Posts: n/a
Default Re: Passing a java array in to a DB2 stored procedure

Eugene,

I don't think there is an alternative, although I'm no JDBC expert.
Can you elaborate on why a temp table is not an option?

Cheers
Serge
--
Serge Rielau
DB2 SQL Compiler Development
IBM Toronto Lab
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 02-26-2008, 06:03 PM
Eugene
 
Posts: n/a
Default Re: Passing a java array in to a DB2 stored procedure

Serge Rielau <srielau@ca.eye-be-em.com> wrote in message news:<c08h5a$2pv$1@hanover.torolab.ibm.com>...
> Eugene,
>
> I don't think there is an alternative, although I'm no JDBC expert.
> Can you elaborate on why a temp table is not an option?
>
> Cheers
> Serge



Hi Serge,

Yes... finaly we adjusted the java app to utilize temp tables as a
workaround. But the goal was to minimize volume of calls to the
database from the client via jdbc and taking advantages of stored
procs as much as possible.

Regards,
-Eugene
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 02-26-2008, 06:03 PM
Serge Rielau
 
Posts: n/a
Default Re: Passing a java array in to a DB2 stored procedure

Eugene,

If you want to minimize calls to DB2 then here is a thought:
Can you use a normal Java function invocation in these cases and push
the JDBC horizon down further?

Cheers
Serge
--
Serge Rielau
DB2 SQL Compiler Development
IBM Toronto Lab
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 02-26-2008, 06:04 PM
Eugene
 
Posts: n/a
Default Re: Passing a java array in to a DB2 stored procedure

Serge,

Can you please clarify your point, an example would be ideal.

Thanks,
-Eugene


"Serge Rielau" <srielau@ca.eye-be-em.com> wrote in message
news:c0aq69$ous$1@hanover.torolab.ibm.com...
> Eugene,
>
> If you want to minimize calls to DB2 then here is a thought:
> Can you use a normal Java function invocation in these cases and push
> the JDBC horizon down further?
>
> Cheers
> Serge
> --
> Serge Rielau
> DB2 SQL Compiler Development
> IBM Toronto Lab



Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 02-26-2008, 06:04 PM
Serge Rielau
 
Posts: n/a
Default Re: Passing a java array in to a DB2 stored procedure

If I knew Java.....let me try C

Insetad of

CREATE PROCEDURE p1(IN arg ARRAY[10])
BEGIN
...
LOOP through arg...
INSERT .....
END LOOP
END

App:
EXEC SQL CALL p1(array);

use

void p1(array *arg)
{
for (i = 0, i < 10, i++)
{
val = arg[i];
EXEC SQL INSERT .....;
}
}

App:
....
p1(arg);
....

--
Serge Rielau
DB2 SQL Compiler Development
IBM Toronto Lab
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 09:07 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com