X-Original-To: pgsql-sql@postgresql.org Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 0953C475D00 for ; Fri, 14 Feb 2003 04:16:02 -0500 (EST) Received: from matrix.gatewaynet.com (unknown [217.19.69.50]) by postgresql.org (Postfix) with ESMTP id ED300475C2B for ; Fri, 14 Feb 2003 04:15:56 -0500 (EST) Received: from matrix.gatewaynet.com (matrix.gatewaynet.com [217.19.69.50] (may be forged)) by matrix.gatewaynet.com (8.12.5/8.12.5) with ESMTP id h1EDHVIs021367; Fri, 14 Feb 2003 11:17:31 -0200 Received: from localhost (achill@localhost) by matrix.gatewaynet.com (8.12.5/8.12.5/Submit) with ESMTP id h1EDHVTv021363; Fri, 14 Feb 2003 11:17:31 -0200 Date: Fri, 14 Feb 2003 11:17:31 -0200 (GMT+2) From: Achilleus Mantzios To: David Durst Cc: pgsql-sql@postgresql.org Subject: Re: Passing arrays In-Reply-To: <42097.216.86.192.34.1045213079.squirrel@www.la-rubber.com> Message-ID: MIME-Version: 1.0 Content-Type: MULTIPART/MIXED; BOUNDARY="8323328-2067803833-1045228651=:21195" X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200302/325 X-Sequence-Number: 11723 This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. Send mail to mime@docserver.cac.washington.edu for more info. --8323328-2067803833-1045228651=:21195 Content-Type: TEXT/PLAIN; charset=US-ASCII On Fri, 14 Feb 2003, David Durst wrote: > 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? You can always parse SELECT array_dims()::text from ; Or write a function using the macros in /usr/local/pgsql/include/server/utils/array.h to get the size of each dimension. (i have attached a simple function that does that) > > 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) > ================================================================== 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 --8323328-2067803833-1045228651=:21195 Content-Type: TEXT/PLAIN; charset=US-ASCII; name="arrlevel.c" Content-Transfer-Encoding: BASE64 Content-ID: Content-Description: Content-Disposition: attachment; filename="arrlevel.c" I2luY2x1ZGUgInBvc3RncmVzLmgiDQogDQojaW5jbHVkZSAiYWNjZXNzL2dp c3QuaCINCiNpbmNsdWRlICJhY2Nlc3MvaXR1cC5oIg0KI2luY2x1ZGUgImFj Y2Vzcy9ydHJlZS5oIg0KI2luY2x1ZGUgInV0aWxzL2Vsb2cuaCINCiNpbmNs dWRlICJ1dGlscy9wYWxsb2MuaCINCiNpbmNsdWRlICJ1dGlscy9hcnJheS5o Ig0KI2luY2x1ZGUgInV0aWxzL2J1aWx0aW5zLmgiDQojaW5jbHVkZSAic3Rv cmFnZS9idWZwYWdlLmgiDQoNClBHX0ZVTkNUSU9OX0lORk9fVjEobGV2ZWwp Ow0KRGF0dW0gbGV2ZWwoUEdfRlVOQ1RJT05fQVJHUyk7IA0KDQpEYXR1bSBs ZXZlbChQR19GVU5DVElPTl9BUkdTKQ0Kew0KCWludCBuaXRlbXMsbmRpbSwq ZGltOw0KCWNoYXIgKnA9MDsNCglBcnJheVR5cGUgKmludGFycmF5ID0gKEFy cmF5VHlwZSAqKSBEYXR1bUdldFBvaW50ZXIoUEdfR0VUQVJHX0RBVFVNKDAp KTsNCglpZiAgKGludGFycmF5ID09IDAgKSByZXR1cm4gKGludDQpIDA7DQoJ aW50YXJyYXkgPSBEYXR1bUdldEFycmF5VHlwZVAoUG9pbnRlckdldERhdHVt KGludGFycmF5KSk7DQoJaWYgIChpbnRhcnJheSA9PSAwICkgcmV0dXJuIChp bnQ0KSAwOw0KCXAgPSBBUlJfREFUQV9QVFIoaW50YXJyYXkpOw0KCWlmIChw ID09IDApIHJldHVybiAoaW50NCkgMDsNCgluZGltID0gQVJSX05ESU0oaW50 YXJyYXkpOw0KCWRpbSA9IEFSUl9ESU1TKGludGFycmF5KTsNCgluaXRlbXMg PSBBcnJheUdldE5JdGVtcyhuZGltLCBkaW0pOw0KCXJldHVybiAoaW50NCkg bml0ZW1zOw0KfQ0K --8323328-2067803833-1045228651=:21195--