X-Original-To: pgsql-sql@postgresql.org Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 4964B475B8E for ; Fri, 14 Feb 2003 04:14:40 -0500 (EST) Received: from vision1.touristvision.com.au (vision1.corpusglobe.com [202.61.128.2]) by postgresql.org (Postfix) with ESMTP id BA029475B8A for ; Fri, 14 Feb 2003 04:14:36 -0500 (EST) Received: by VISION1 with Internet Mail Service (5.5.2653.19) id ; Fri, 14 Feb 2003 17:29:42 +0800 Message-ID: <3B663B41B350D311AEEF00A0C9254563201A73@VISION1> From: Michael Weaver To: "'ddurst@larubber.com'" , pgsql-sql@postgresql.org Subject: Re: Passing arrays Date: Fri, 14 Feb 2003 17:29:36 +0800 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2653.19) Content-Type: multipart/alternative; boundary="----_=_NextPart_001_01C2D40B.975E3EA0" X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200302/324 X-Sequence-Number: 11722 This message is in MIME format. Since your mail reader does not understand this format, some or all of this message may not be legible. ------_=_NextPart_001_01C2D40B.975E3EA0 Content-Type: text/plain; charset="iso-8859-1" There is a function array_dims(array) that returns the size of array. It's not THAT useful as it returns a string like '[1:2]' <-( 1 lower, 2 upper bound.) With a little bit of string processing you could get the size of the array. > -----Original Message----- > From: David Durst [mailto:ddurst@larubber.com] > Sent: Friday, 14 February 2003 4:58 PM > To: pgsql-sql@postgresql.org > Subject: Re: [SQL] Passing arrays > > > This is slightly off the original topic but related. > > Is there any function or way I can easily find the size of > the passed array? > > On Fri, 14 Feb 2003, Michael Weaver wrote: > > > >> > >> > >> > -----Original Message----- > >> > From: Stephan Szabo [mailto:sszabo@megazone23.bigpanda.com] > >> > Sent: Friday, 14 February 2003 12:58 PM > >> > To: Michael Weaver > >> > Cc: 'pgsql-novice@postgresql.org'; 'pgsql-sql@postgresql.org' > >> > Subject: Re: [SQL] Passing arrays > >> > > >> > > >> > > >> > On Fri, 14 Feb 2003, Michael Weaver wrote: > >> > > >> > > How do you get an array of elements to be passed to a > >> > stored proc such that > >> > > you can use the array in a SELECT statement in the WHERE clause > >> > > - e.g. WHERE field IN (array) etc... > >> > > >> > A straight WHERE field IN (array) doesn't work. That's > attempting > >> to compare the field directly to the array as a whole (which is > >> > why you get > >> > the particular error you do. > >> > >> I've got around this limitation using strings, but I do find it > >> suprising, that Postgres handles arrays this way. > >> Searching an array in an WHERE IN clause would be a useful task. > >> (namely for passing arrays of values between stored functions) > >> > >> Ok it could be confusing, but I think a number of other > DBs employ it > >> to good effect. > >> > >> I'll take a look at the array extension in contrib - it > sounds useful. > > > > Also check out contrib/intarray and its indexing capabilites > > if you have 1 dimensional integer arrays. > > > >> > >> Thanks. > >> > > > > ================================================================== > > Achilleus Mantzios > > S/W Engineer > > IT dept > > Dynacom Tankers Mngmt > > Nikis 4, Glyfada > > Athens 16610 > > Greece > > tel: +30-10-8981112 > > fax: +30-10-8981877 > > email: achill@matrix.gatewaynet.com > > mantzios@softlab.ece.ntua.gr > > > > > > ---------------------------(end of > broadcast)--------------------------- > > TIP 1: subscribe and unsubscribe commands go to > majordomo@postgresql.org > > > > > ---------------------------(end of > broadcast)--------------------------- > TIP 2: you can get off all lists at once with the unregister command > (send "unregister YourEmailAddressHere" to > majordomo@postgresql.org) > ------_=_NextPart_001_01C2D40B.975E3EA0 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable RE: [SQL] Passing arrays

There is a function array_dims(array) that returns the si= ze of array.
It's not THAT useful as it returns a string like '[1:2]'= <-( 1 lower, 2 upper bound.)
With a little bit of string processing you could get the= size of the array.



> -----Original Message-----
> From: David Durst [mailto:ddurst@larubber.com]
> Sent: Friday, 14 February 2003 4:58 PM
> To: pgsql-sql@postgresql.org
> Subject: Re: [SQL] Passing arrays
>
>
> This is slightly off the original topic but related= .
>
> Is there any function or way I can easily find the = size of
> the passed array?
> > On Fri, 14 Feb 2003, Michael Weaver wrote:
> >
> >>
> >>
> >> > -----Original Message-----
> >> > From: Stephan Szabo [mailto:sszabo@megazone23.bigpanda.com= ]
> >> > Sent: Friday, 14 February 2003 12:58 = PM
> >> > To: Michael Weaver
> >> > Cc: 'pgsql-novice@postgresql.org'; 'p= gsql-sql@postgresql.org'
> >> > Subject: Re: [SQL] Passing arrays
> >> >
> >> >
> >> >
> >> > On Fri, 14 Feb 2003, Michael Weaver w= rote:
> >> >
> >> > > How do you get an array of eleme= nts to be passed to a
> >> > stored proc such that
> >> > > you can use the array in a SELEC= T statement in the WHERE clause
> >> > >  - e.g.  WHERE field I= N (array) etc...
> >> >
> >> > A straight WHERE field IN (array) doe= sn't work.  That's
> attempting
> >> to compare the field directly to the array= as a whole (which is
> >> > why you get
> >> > the particular error you do.
> >>
> >> I've got around this limitation using stri= ngs, but I do find it
> >> suprising, that Postgres handles arrays th= is way.
> >> Searching an array in an WHERE IN clause w= ould be a useful task.
> >> (namely for passing arrays of values betwe= en stored functions)
> >>
> >> Ok it could be confusing, but I think a nu= mber of other
> DBs employ it
> >> to good effect.
> >>
> >> I'll take a look at the array extension in= contrib - it
> sounds useful.
> >
> > Also check out contrib/intarray and its indexi= ng capabilites
> > if you have 1 dimensional integer arrays.
> >
> >>
> >> Thanks.
> >>
> >
> > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D
> > Achilleus Mantzios
> > S/W Engineer
> > IT dept
> > Dynacom Tankers Mngmt
> > Nikis 4, Glyfada
> > Athens 16610
> > Greece
> > tel:    +30-10-8981112
> > fax:    +30-10-8981877
> > email:  achill@matrix.gatewaynet.com
> >        = ; mantzios@softlab.ece.ntua.gr
> >
> >
> > ---------------------------(end of
> broadcast)---------------------------
> > TIP 1: subscribe and unsubscribe commands go t= o
> majordomo@postgresql.org
>
>
>
>
> ---------------------------(end of
> broadcast)---------------------------
> TIP 2: you can get off all lists at once with the u= nregister command
>     (send "unregister Your= EmailAddressHere" to
> majordomo@postgresql.org)
>

------_=_NextPart_001_01C2D40B.975E3EA0--