Re: Using composite types within PLPGSQL Function

From: Leif Biberg Kristensen <leif(at)solumslekt(dot)org>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Using composite types within PLPGSQL Function
Date: 2013-01-08 15:35:34
Message-ID: 201301081635.34337.leif@solumslekt.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Tirsdag 8. januar 2013 16.10.03 skrev Graeme Hinchliffe :
> My example code is :
>
> CREATE TYPE testtype AS (
> a INTEGER,
> b INTEGER
> );
>
> CREATE OR REPLACE FUNCTION test() RETURNS INTEGER AS $$
> DECLARE
> x testtype;
> BEGIN
> (x).a:=1;
> RETURN 1;
> END
> $$ LANGUAGE plpgsql;
>
> This throws up syntax errors for the (x).a:=1; line.. I have also tried
> SELECT INTO (x).a 1;
>
> Any help much appreciated, version of PostgreSQL is 8.4 under Debian.

It should work with

x.a := 1;

without the parentheses. See http://solumslekt.org/blog/?p=91 for an example
of composite types and functions.

regards, Leif

In response to

Browse pgsql-general by date

  From Date Subject
Next Message James Cowell 2013-01-08 17:00:50 Re: [Solved] Corrupt indexes on slave when using pg_bulkload on master
Previous Message Adrian Klaver 2013-01-08 15:27:21 Re: Query with LIMIT but as random result set?