Re: Arrays in pgsql - Mailing list pgsql-general

From Gregory Wood
Subject Re: Arrays in pgsql
Date
Msg-id 015d01c1c37b$69ec1d80$7889ffcc@comstock.com
Whole thread Raw
In response to Arrays in pgsql  (Martina Mostert <martina_mostert@gmx.de>)
List pgsql-general
> I'm working on a plpgsql-function. I need an array of type integer. The
> Programmer's Guide says 'PL/pgSQL variables can have any SQL datatype',
> so I'd say there should also be arrays - or am I wrong?

You'd be wrong... arrays are *not* an SQL datatype. Arrays are a PostgreSQL
construct.

> monthday integer[12];

> Any suggestions?

The closest thing I can come up with is creating a simple table with an
integer array column as a template, then you can declare a variable with a
TYPE matching that table. For example:

CREATE TABLE int_array_table (int_array integer[12]);

Then you can say:

monthday int_array_table.int_array%TYPE

But to be honest, I haven't tried this, so I can't say if it works or not.

Greg


pgsql-general by date:

Previous
From: "Gregory Wood"
Date:
Subject: Re: oids vs. serial question
Next
From: "Raymond O'Donnell"
Date:
Subject: Re: SQL question - duplicate records from join