X-Original-To: pgsql-sql@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id F28184763D2 for ; Thu, 8 May 2003 06:39:47 -0400 (EDT) Received: from matrix.gatewaynet.com (unknown [217.19.69.50]) by postgresql.org (Postfix) with ESMTP id 5B9164765DF for ; Thu, 8 May 2003 06:39:19 -0400 (EDT) Received: from matrix.gatewaynet.com (localhost [127.0.0.1]) by matrix.gatewaynet.com (8.12.5/8.12.5) with ESMTP id h48Fi41s001352; Thu, 8 May 2003 13:44:04 -0200 Received: from localhost (achill@localhost) by matrix.gatewaynet.com (8.12.5/8.12.5/Submit) with ESMTP id h48Fi4nV001348; Thu, 8 May 2003 13:44:04 -0200 Date: Thu, 8 May 2003 13:44:04 -0200 (GMT+2) From: Achilleus Mantzios To: Victor Yegorov Cc: Postgres SQL Subject: Re: Array dimension as integer In-Reply-To: <20030508095745.GA22337@nordlb.lv> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Spam-Status: No, hits=-38.0 required=5.0 tests=BAYES_01,EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT, REPLY_WITH_QUOTES,SIGNATURE_LONG_DENSE,USER_AGENT_PINE autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200305/162 X-Sequence-Number: 13327 On Thu, 8 May 2003, Victor Yegorov wrote: > Hello. > > I'm using: > > PostgreSQL 7.3.2 on i686-pc-linux-gnu, compiled by GCC 2.95.3 > > and I'd like to have a function, which would receive array of varchars and then > create and EXECUTE insert statement for each of array elements (array has 1 > dimension): > > FOR i IN 1..array_length_function($1) LOOP > EXECUTE ...; > END LOOP; > > I've tried to use array_dims, but it gives data in string format: > > select test_array('{\'a\'}'); > WARNING: Error occurred while executing PL/pgSQL function test_array > WARNING: line 8 at select into variables > ERROR: pg_atoi: error in "[1:1]": can't parse "[1:1]" use something like substr(array_dims(yourTable.yourArrayColumn),4,1)::int to get the dim in [1xN] arrays > > I've attached test_array source. > > -- ================================================================== Achilleus Mantzios S/W Engineer IT dept Dynacom Tankers Mngmt Nikis 4, Glyfada Athens 16610 Greece tel: +30-210-8981112 fax: +30-210-8981877 email: achill@matrix.gatewaynet.com mantzios@softlab.ece.ntua.gr