pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Achilleus Mantzios <achill@matrix.gatewaynet.com>
To: Victor Yegorov <viy@nordlb.lv>
Cc: Postgres SQL <pgsql-sql@postgresql.org>
Subject: Re: Array dimension as integer
Date: Thu, 8 May 2003 13:44:04 -0200 (GMT+2)
Message-ID: <Pine.LNX.4.44.0305081342050.868-100000@matrix.gatewaynet.com> (raw)
In-Reply-To: <20030508095745.GA22337@nordlb.lv>

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




view thread (2+ messages)

Message-ID: <Pine.LNX.4.44.0305081342050.868-100000@matrix.gatewaynet.com>
Permalink:  ../Pine.LNX.4.44.0305081342050.868-100000@matrix.gatewaynet.com/
Also on:    postgresql.org/message-id/Pine.LNX.4.44.0305081342050.868-100000@matrix.gatewaynet.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: achill@matrix.gatewaynet.com, viy@nordlb.lv
  Subject: Re: Array dimension as integer
  In-Reply-To: <Pine.LNX.4.44.0305081342050.868-100000@matrix.gatewaynet.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox