Re: [SQL] Is there a type like a growable array, similar Vector at

2005-07-23 Thread Richard Huxton
Dongsoo Yoon wrote:
> In Oracle, there is a type like a growable array, similar Vector at
> Java language.


I always find the manuals good for this information. Looking in the
section on "Arrays", in "Data Types"

BEGIN QUOTE
A stored array value can be enlarged by assigning to an element adjacent
to those already present, or by assigning to a slice that is adjacent to
or overlaps the data already present. For example, if array myarray
currently has 4 elements, it will have five elements after an update
that assigns to myarray[5]. Currently, enlargement in this fashion is
only allowed for one-dimensional arrays, not multidimensional arrays.
END QUOTE

Is that helpful?
-- 
  Richard Huxton
  Archonet Ltd

---(end of broadcast)---
TIP 4: Have you searched our list archives?

   http://archives.postgresql.org


Re: [SQL] Multi-column returns from pgsql

2005-07-23 Thread Jim Buttafuoco

or just return setof RECORD (version 7.4 +)


-- Original Message ---
From: Tony Wasson <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED]
Cc: "Mark R. Dingee" <[EMAIL PROTECTED]>, pgsql-sql@postgresql.org
Sent: Fri, 22 Jul 2005 11:11:09 -0700
Subject: Re: [SQL] Multi-column returns from pgsql

> On 7/22/05, Jim Buttafuoco <[EMAIL PROTECTED]> wrote:
> > Mark,
> > 
> > Instead of  RETURN NEXT rec.txt1; RETURN NEXT rec.txt2; just use RETURN 
> > NEXT rec;
> > 
> > then your select statement would be
> > select * from my_func() as (txt1 text,txt2 text);
> > 
> > Jim
> 
> Besides a simple RETURN NEXT, you'll need to return a SETOF some
> composite type. You can do something like
> 
> CREATE TYPE twotexts_t AS (txt1 TEXT, txt2 TEXT);
> 
> CREATE OR REPLACE FUNCTION my_func() returns SETOF twotexts_t AS '
> DECLARE
>rec record;
> BEGIN
>FOR rec IN SELECT txt1, txt2 FROM mytable LOOP
>   RETURN NEXT
>END LOOP;
>RETURN;
> END;' language 'plpgsql';
> 
> ---(end of broadcast)---
> TIP 6: explain analyze is your friend
--- End of Original Message ---


---(end of broadcast)---
TIP 2: Don't 'kill -9' the postmaster