Hi,

Yes that works but when I try to put the results of a rowtype returning 
function into a rowtype variable in another function i cannot access the 
individual attributes from variable.  Only from the direct call.

ie.

x1 := (get_defaults_vals()).a1
x2 := (get_defaults_vals()).a2
x3 := (get_defaults_vals()).a3

i can't do

declare
vals default_vals%rowtype
begin
select get_defaults_vals() into vals;

x1 := default_vals.a1;

I can't do this. Postgresql seems to forget what the attributes are if i put 
the results into a rowtype variable.




 -----Original Message-----
From: [EMAIL PROTECTED]
Sent: 12 June 2007 13:49
To: Robert Wickert
Cc: pgsql-general@postgresql.org
Subject: Re: [GENERAL] PL/PGSQL rowtype return pr


   

 --------------------------------------------------------------------------  --
Hello,

my code works well:

CREATE TABLE Foo(a integer, b integer);

CREATE OR REPLACE FUNCTION ret_foo()
RETURNS Foo AS $$
DECLARE r Foo;
BEGIN
  r := (10,20); --default
  RETURN r;
END; $$
LANGUAGE plpgsql;

SELECT ret_foo();

CREATE OR REPLACE FUNCTION trig()
RETURNS TRIGGER AS $$
BEGIN
  NEW := ret_foo();
  RETURN NEW;
END; $$
LANGUAGE plpgsql;

CREATE TRIGGER footrig BEFORE INSERT ON Foo
  FOR EACH ROW EXECUTE PROCEDURE trig();

INSERT INTO Foo VALUES(0,0);

Regards
Pavel Stehule

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

               http://archives.postgresql.org/
*****************************************************
Robert Wickert
Senior Software Developer
CONTEXT
Tel:+44 (0)20 8394 7739
Fax:+44 (0)20 8394 7701
Email Address: [EMAIL PROTECTED]
Web Site: http://www.contextworld.com
*****************************************************
This message and the information contained therein is intended for the use
of the person(s) ("the intended  recipient(s)" to whom it is addressed. It
may contain information that is privileged and confidential within the
meaning of applicable law. If you are not the intended recipient, please
contact the sender as soon possible. The views expressed in this
communication may not necessarily  be the views held by Context or its
subsidiaries. The contents of an attachment to this e-mail may contain
viruses that could damage your own computer system. While every reasonable
precaution has been taken to minimise this risk, Context and its
subsidiaries cannot  accept liability for any damage which you sustain  as a
result of software viruses. You should carry out your own virus checks
before opening the attachment. Please notice that Context monitors e-mails
sent or received. Further communication will signify your consent to this.

---------------------------(end of broadcast)---------------------------
TIP 5: don't forget to increase your free space map settings

Reply via email to