0

I need to take the values from a specific column in a table and place them into an array. I'm thinking to use a PL/SQL Stored procedure then calling the procedure in java and using something like:

    CallableStatement.getArray(2, myArray);

I was thinking of using something like:

SELECT column1 
INTO myVARRAY
FROM table1
WHERE table_id = t_id;

In a stored procedure But that didn't work

1
  • 1
    "But that didn't work". C'mon, give us a clue. How didn't it work? We are not telepathic, so you need to provide details: describe the observed behaviour, results, error messages etc. Commented Nov 17, 2012 at 9:04

1 Answer 1

1

Presume that myVARRAY is of type varchar2. In this case you could try something like

p_col   VARCHAR2 (32);

SELECT column1 
INTO p_col
FROM table1
WHERE table_id = t_id;

and then you add p_col into your array by

myVARRAY.EXTEND;
myVARRAY (1) := p_col;

RETURN myVARRAY;

And from Java call your array by

callablestatement.registerOutParameter(2, OracleTypes.ARRAY, "MYVARRAY");

Hope this will be helpful, otherwise provide more information about your function/procedure and the type of errors you are getting.

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

Comments

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.