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

From Graeme Hinchliffe
Subject Using composite types within PLPGSQL Function
Date
Msg-id B9DA14E6AAF91B49A38521DB214E04D5A2056E4A@MAILISE10MBX2.office.zen.co.uk
Whole thread Raw
Responses Re: Using composite types within PLPGSQL Function  (Leif Biberg Kristensen <leif@solumslekt.org>)
List pgsql-general

Hi,

                I am trying to use a composite type within a function, I have tried SELECT INTO and direct assignment to set the value of a single element within the composite variable with no joy.  I hope this is simply a case of my not knowing the correct syntax?

 

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.

 

Thanks

 

Graeme

--
Graeme Hinchliffe
Senior Systems Designer, Zen Internet
T: 0845 058 9000
F: 0845 058 9005
W: zen.co.uk

BT have increased their monthly phone line rental to £15.45 per month. Our remains at £11.22. Switch now : http://www.zen.co.uk/home-office/voice/phone-services.aspx

This message is private and confidential. If you have received this message in error, please notify us and remove it from your system.

Zen Internet Limited may monitor email traffic data to manage billing, to handle customer enquiries and for the prevention and detection of fraud. We may also monitor the content of emails sent to and/or from Zen Internet Limited for the purposes of security, staff training and to monitor quality of service.

Zen Internet Limited is registered in England and Wales, Sandbrook Park, Sandbrook Way, Rochdale, OL11 1RY Company No. 03101568 VAT Reg No. 686 0495 01

pgsql-general by date:

Previous
From: "ac@hsk.hk"
Date:
Subject: Questions about 9.2 unique constraints
Next
From: Wolfgang Keller
Date:
Subject: Re: Database Design: Maintain Audit Trail of Changes