Re: how to pass an array of integers into a Stored Procedure ?
Posted in 2005
Topics: Stored Procedures & SPL, Connectivity: ODBC / JDBC / .NET
Jlukar wrote:
> Is this possible ?
Is what possible?
>
> I have an varying length set of integers, I like to pass into SPL and
> then iterate over them and insert a row into a table for each one of
> the integers using the SPL.
>
> is this at all possible ?
Yes.
>
> I know I can pass in SET types, that inserts an array of integers into
> a single column, for a single row, but this isn't what I need.
You can iterate over a set, eg:
create procedure proc(x set(integer not null))...
define y integer;
foreach
select *
into y
from table(x)
-- do stuff ...
end foreach
>
> I am using JDBC to do this and it seems there is no easy way of doing.
>
> My main goal is to avoid hitting the database for every insert of the
> integer into the table row.
You're never going to avoid hitting the database every time you insert a
row.
> any ideas ?
Probably what you need is to put an insert cursor, I don't know if jdbc
has them.
Thats perfect and what I needed to know to iterate over a set. What I meant was I wanted to avoid calling the SPL from my java program for every row I wanted to insert to minimize program to DB communication overhead. thanks much.