Re: IN clauses via setObject(Collection) [Was: Re: Prepare

From: Darin Ohashi <DOhashi(at)maplesoft(dot)com>
To: "'Dmitry Tkach'" <dmitry(at)openratings(dot)com>, Darin Ohashi <DOhashi(at)maplesoft(dot)com>
Cc: "'Oliver Jowett'" <oliver(at)opencloud(dot)com>, Fernando Nasser <fnasser(at)redhat(dot)com>, Kim Ho <kho(at)redhat(dot)com>, Barry Lind <blind(at)xythos(dot)com>, pgsql-jdbc-list <pgsql-jdbc(at)postgresql(dot)org>, Dave Cramer <Dave(at)micro-automation(dot)net>
Subject: Re: IN clauses via setObject(Collection) [Was: Re: Prepare
Date: 2003-07-21 20:20:45
Message-ID: F17255C2B596D3119A5600508B44FA68052EB877@courier.maplesoft.on.ca
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc


> I am not talking about names. I don't care what the name of
> datatype is.
> Since I can create a datatype to represent a set, that, accroding to
> your logic, makes it "data" (because I can create a table
> column of that
> type, and store a set in it), thus, there should be a way to
> pass it in
> through jdbc.
> This is what *you* said, not me.

You are missing something here. In the original select statement that started
this mess of a discussion, you wanted to pass the SQL set Syntax into a
PreparedStatement. Something like this:

PreparedStatement stmt = c.prepareStatement("select * from mytable where data in
?");
stmt.setObject (1, "(1,2,3,4,5)", Types.INTEGER);

I questioned if passing the syntax of an SQL set was valid, stating my belief
that only passing data via a ? was valid, and stating my definition that data is
something that can be stored in a column. You claimed that because you can
create a new datatype for representing a set that sets are data. However that
has nothing to do with the orignal question. If you created a set datatype, it
would be passed to a PreparedStatement as a single data element (a single data
element that contained other data). In particular it would not have the correct
syntax to work in the example above.

So, yes you should be able to create a set datatype and pass that into the
PreparedStatment (JDBC allows for this using the SQLData interface, I don't know
if postgresql supports it), but the data that is representing a set datatype
would not be able to be inserted where SQL set Syntax is expected. The set
datatype and the SQL set Syntax are completely distinct objects.

Darin

PS. This will be my last post on this subject. I think that my thoughts on it
have been made clear.

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Dmitry Tkach 2003-07-21 20:31:33 Re: IN clauses via setObject(Collection) [Was: Re: Prepare
Previous Message Dmitry Tkach 2003-07-21 20:14:33 Re: IN clauses via setObject(Collection) [Was: Re: Prepare