0

I'm currently working with trying to compare an ID in Oracle(A VARCHAR2) with an array of IDs I have as input.

This is what I want to do:

Select user, city where id = :arrayOfIds

In Postgres with JDBC I would use:

Select user, city where id = any(:arrayOfIds)

Is there an equivalent function in Oracle, or a way to do this?

0

1 Answer 1

1

You should use:

Select user, city where id in (:arrayOfIds)

and in you code, you need to trasform your array in string with ids:

arrayOfIds[0] --> 1
arrayOfIds[1] --> 3
arrayOfIds[2] --> 5

... in

1, 3, 5, ...

and you can use:

Array array = conn.createArrayOf("arrayOfIds", new Object[]{"1", "2","3"});
pstmt.setArray(1, array);

How to use an arraylist as a prepared statement parameter

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

1 Comment

The Oracle JDBC driver does not support createArrayOf()

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.