Skip site navigation (1) Skip section navigation (2)

selecting using array as IN condition parameter - possible?

From: "John Lister" <john(dot)lister(at)kickstone(dot)com>
To: <pgsql-jdbc(at)postgresql(dot)org>
Subject: selecting using array as IN condition parameter - possible?
Date: 2010-09-29 12:59:27
Message-ID: 021A4E50B9DC4D9FA01652B91A8011A0@squarepi.com (view raw or flat)
Thread:
Lists: pgsql-jdbc
Hi, suppose I have a query such as

select * from blah where (a,b) in ( (1,2),(2,3),(3,4)...) 

I'd like to do this using jdbc and use a list/array for the IN parameter.

using postgresql 8.3, it is possible to rewrite it so that I am passing in an array instead of a hardcoded list as so

select * from blah where (a, b)::myPairType = any ( array of myPairType) 

provided I've created a type (myPairType) to represent my data pair and a comparison operator for the new data type.

My question is therefore is it possible to pass an array of this type using jdbc or alternatively pass an array of arrays to represent my pair and convert that in the sql?

Thanks

John
--

Got needs? Get Goblin'! - http://www.pricegoblin.co.uk/

pgsql-jdbc by date

Next:From: Oliver JowettDate: 2010-09-29 13:02:48
Subject: Re: [BUGS] Mapping Hibernate boolean to smallint(Postgresql)
Previous:From: stagirusDate: 2010-09-29 12:16:45
Subject: Re: [BUGS] Mapping Hibernate boolean to smallint(Postgresql)

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group