Home » Open Source » Programming Interfaces » Multiple value parameters with JDBC (Oracle 9i/10g, JDBC THIN driver)
Multiple value parameters with JDBC [message #351721] Thu, 02 October 2008 14:27 Go to next message
dandormont
Messages: 12
Registered: April 2006
Junior Member
Can I pass multiple values to a parameter or bind variable? For example if I have a SQL statement like:

select * from users where user_id in (?)


I'd like to pass multiple values for my user_id parameter. Suppose that programmatically, at the time I'm constructing the SQL statement, I don't know how many values I'd like to pass. My application uses the Oracle JDBC THIN driver and needs to run on both 9i and 10g databases. thanks
Re: Multiple value parameters with JDBC [message #351730 is a reply to message #351721] Thu, 02 October 2008 14:54 Go to previous messageGo to next message
Michel Cadot
Messages: 68625
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Search for "varying in list" or "string list" or the like.

Regards
Michel
Re: Multiple value parameters with JDBC [message #351865 is a reply to message #351730] Fri, 03 October 2008 08:57 Go to previous messageGo to next message
dandormont
Messages: 12
Registered: April 2006
Junior Member
Ok so it looks like the proposed solutions are a) create a custom SQL type and a split() function to go along with that, or b) create a temporary table. Those solutions are straightforward enough, but I don't control the target database and my user may not have CREATE FUNCTION, CREATE TYPE or CREATE TABLE privileges. I was hoping I could do something like attach an array to the bind variable itself. Is there a facility for that?
Re: Multiple value parameters with JDBC [message #351881 is a reply to message #351865] Fri, 03 October 2008 10:13 Go to previous messageGo to next message
Michel Cadot
Messages: 68625
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
No.
The appropriate features are those you don't want to use.

By the way, what should you say if someone told you have to write a program but you can't use any function?

Regards
Michel
Re: Multiple value parameters with JDBC [message #351883 is a reply to message #351881] Fri, 03 October 2008 10:34 Go to previous messageGo to next message
dandormont
Messages: 12
Registered: April 2006
Junior Member
Your point is well taken, but at the same time I don't think it's so unreasonable to think that one might have a database that allows a certain application to talk to it with limited privileges, namely to run SELECT statements on certain tables/views and execute certain functions...
Re: Multiple value parameters with JDBC [message #351890 is a reply to message #351883] Fri, 03 October 2008 11:22 Go to previous message
Michel Cadot
Messages: 68625
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Quote:
might have a database that allows a certain application to talk to it with limited privileges,

To talk yes, but to develop them, it is doubtful above when it is about creating objects.
Same thing that you can't create new classes in Java.
You don't create them on the fly. You create them for your application to work with.

Regards
Michel
Previous Topic: ODBC error
Next Topic: problem with VB6, ODBC, Access, ORACLE 9i, UNIX
Goto Forum:
  


Current Time: Thu Mar 28 14:11:40 CDT 2024