Re: Array dimension as integer

From: Achilleus Mantzios <achill(at)matrix(dot)gatewaynet(dot)com>
To: Victor Yegorov <viy(at)nordlb(dot)lv>
Cc: Postgres SQL <pgsql-sql(at)postgresql(dot)org>
Subject: Re: Array dimension as integer
Date: 2003-05-08 15:44:04
Message-ID: Pine.LNX.4.44.0305081342050.868-100000@matrix.gatewaynet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

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(at)matrix(dot)gatewaynet(dot)com
mantzios(at)softlab(dot)ece(dot)ntua(dot)gr

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message mallah 2003-05-08 15:45:32 Re: PROBLEM WITH UPDATE COMMAND
Previous Message mallah 2003-05-08 15:17:46 Re: seeing type defination..