Re: Passing arrays - Mailing list pgsql-sql
From | Michael Weaver |
---|---|
Subject | Re: Passing arrays |
Date | |
Msg-id | 3B663B41B350D311AEEF00A0C9254563201A73@VISION1 Whole thread Raw |
In response to | Passing arrays (Michael Weaver <mweaver@corpusglobe.com>) |
List | pgsql-sql |
<p><font size="2">There is a function array_dims(array) that returns the size of array.</font><br /><font size="2">It's notTHAT useful as it returns a string like '[1:2]' <-( 1 lower, 2 upper bound.)</font><br /><font size="2">With a littlebit of string processing you could get the size of the array.</font><br /><br /><p><font size="2">> -----OriginalMessage-----</font><br /><font size="2">> From: David Durst [<a href="mailto:ddurst@larubber.com">mailto:ddurst@larubber.com</a>]</font><br/><font size="2">> Sent: Friday, 14 February2003 4:58 PM</font><br /><font size="2">> To: pgsql-sql@postgresql.org</font><br /><font size="2">> Subject:Re: [SQL] Passing arrays</font><br /><font size="2">> </font><br /><font size="2">> </font><br /><font size="2">>This is slightly off the original topic but related.</font><br /><font size="2">> </font><br /><font size="2">>Is there any function or way I can easily find the size of </font><br /><font size="2">> the passed array?</font><br/><font size="2">> > On Fri, 14 Feb 2003, Michael Weaver wrote:</font><br /><font size="2">> ></font><br/><font size="2">> >></font><br /><font size="2">> >></font><br /><font size="2">> >>> -----Original Message-----</font><br /><font size="2">> >> > From: Stephan Szabo [<a href="mailto:sszabo@megazone23.bigpanda.com">mailto:sszabo@megazone23.bigpanda.com</a>]</font><br/><font size="2">> >>> Sent: Friday, 14 February 2003 12:58 PM</font><br /><font size="2">> >> > To: Michael Weaver</font><br/><font size="2">> >> > Cc: 'pgsql-novice@postgresql.org'; 'pgsql-sql@postgresql.org'</font><br/><font size="2">> >> > Subject: Re: [SQL] Passing arrays</font><br /><fontsize="2">> >> ></font><br /><font size="2">> >> ></font><br /><font size="2">> >>></font><br /><font size="2">> >> > On Fri, 14 Feb 2003, Michael Weaver wrote:</font><br /><font size="2">>>> ></font><br /><font size="2">> >> > > How do you get an array of elements to be passedto a</font><br /><font size="2">> >> > stored proc such that</font><br /><font size="2">> >> >> you can use the array in a SELECT statement in the WHERE clause</font><br /><font size="2">> >> > > - e.g. WHERE field IN (array) etc...</font><br /><font size="2">> >> ></font><br /><font size="2">>>> > A straight WHERE field IN (array) doesn't work. That's </font><br /><font size="2">> attempting</font><br/><font size="2">> >> to compare the field directly to the array as a whole (which is</font><br/><font size="2">> >> > why you get</font><br /><font size="2">> >> > the particularerror you do.</font><br /><font size="2">> >></font><br /><font size="2">> >> I've got aroundthis limitation using strings, but I do find it</font><br /><font size="2">> >> suprising, that Postgres handlesarrays this way.</font><br /><font size="2">> >> Searching an array in an WHERE IN clause would be a usefultask.</font><br /><font size="2">> >> (namely for passing arrays of values between stored functions)</font><br/><font size="2">> >></font><br /><font size="2">> >> Ok it could be confusing, butI think a number of other </font><br /><font size="2">> DBs employ it</font><br /><font size="2">> >> to goodeffect.</font><br /><font size="2">> >></font><br /><font size="2">> >> I'll take a look at the arrayextension in contrib - it </font><br /><font size="2">> sounds useful.</font><br /><font size="2">> ></font><br/><font size="2">> > Also check out contrib/intarray and its indexing capabilites</font><br /><font size="2">>> if you have 1 dimensional integer arrays.</font><br /><font size="2">> ></font><br /><font size="2">>>></font><br /><font size="2">> >> Thanks.</font><br /><font size="2">> >></font><br/><font size="2">> ></font><br /><font size="2">> > ==================================================================</font><br/><font size="2">> > Achilleus Mantzios</font><br/><font size="2">> > S/W Engineer</font><br /><font size="2">> > IT dept</font><br /><fontsize="2">> > Dynacom Tankers Mngmt</font><br /><font size="2">> > Nikis 4, Glyfada</font><br /><font size="2">>> Athens 16610</font><br /><font size="2">> > Greece</font><br /><font size="2">> > tel: +30-10-8981112</font><br/><font size="2">> > fax: +30-10-8981877</font><br /><font size="2">> > email: achill@matrix.gatewaynet.com</font><br/><font size="2">> > mantzios@softlab.ece.ntua.gr</font><br /><font size="2">>></font><br /><font size="2">> ></font><br /><font size="2">> > ---------------------------(endof </font><br /><font size="2">> broadcast)---------------------------</font><br /><fontsize="2">> > TIP 1: subscribe and unsubscribe commands go to </font><br /><font size="2">> majordomo@postgresql.org</font><br/><font size="2">> </font><br /><font size="2">> </font><br /><font size="2">></font><br /><font size="2">> </font><br /><font size="2">> ---------------------------(end of </font><br/><font size="2">> broadcast)---------------------------</font><br /><font size="2">> TIP 2: you can getoff all lists at once with the unregister command</font><br /><font size="2">> (send "unregister YourEmailAddressHere"to </font><br /><font size="2">> majordomo@postgresql.org)</font><br /><font size="2">> </font>