Re: Using composite types within PLPGSQL Function - Mailing list pgsql-general

From Leif Biberg Kristensen
Subject Re: Using composite types within PLPGSQL Function
Date
Msg-id 201301081635.34337.leif@solumslekt.org
Whole thread Raw
In response to Using composite types within PLPGSQL Function  (Graeme Hinchliffe <graeme.hinchliffe@zeninternet.co.uk>)
List 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


pgsql-general by date:

Previous
From: Adrian Klaver
Date:
Subject: Re: Query with LIMIT but as random result set?
Next
From: James Cowell
Date:
Subject: Re: [Solved] Corrupt indexes on slave when using pg_bulkload on master