Search Postgresql Archives

Re: PL/PGSQL rowtype return pr

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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: pavel.stehule@xxxxxxxxx
Sent: 12 June 2007 13:49
To: Robert Wickert
Cc: pgsql-general@xxxxxxxxxxxxxx
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: rwickert@xxxxxxxxxxxxxxxx
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.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux