0

We need to update DB2 database with following type of data with store procedure from java application.

ManId ManaFirstName ManLastName CubicleId Unit EmpId EmpFirstName EmpLastName
2345  Steeven        Rodrigue   12345RT HR     2456     John        Graham
                                               45464    Peter       Black

Here, the columns related Emp (Emp Id , Emp First Name and Emp Last Name) is actually array, it can any number of employees from my front application for one manager. We need to pass these values in Store Procedure and process in SP. However, I am not able to find any array type datatype in db2.

I know I can take following two approaches :- 1. Delimited value :- Have varchar column and append all the values with help of delimiter and split in SP.

                     2456,John,Graham|45464,Peter,Black

2. Have separate SP and call in batch.

However, I am looking for approach where I can pass them in single go and some more structured datatype. Does DB2 have datatype like array to support this or any way to create custom datatype.

I am using Spring JDBCTemplate at front end to call SP (I am flexible to change that) and DB2 as database.\

P.S. :- Open queries is not option for me , need to call SP only. This SP is going to be called from java directly, so if have to use custom datatype, only scope is to define it in store procedure which is being called

1 Answer 1

1

Since the data types of Emp Id , Emp First Name and Emp Last Name are probably different, you should use a DB2 ROW type to contain them, not ARRAY. In Java that would be represented by java.sql.Struct. You can also pass an ARRAY of ROW types to the stored procedure. Check the manual for details and examples.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for input , It seems ok to me. i will try this tommarrow and will accept answer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.