From: | "Leif B(dot) Kristensen" <leif(at)solumslekt(dot)org> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: Plpgsql functions with output parameters |
Date: | 2009-06-04 12:27:56 |
Message-ID: | 200906041427.56493.leif@solumslekt.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Thursday 4. June 2009, Radcon Entec wrote:
>I have been beating my head against the documentation on plpgsql
> functions with output parameters for the last three hours, but I
> haven't been able to get them to work yet.
>
>
>I am playing with the sum_n_product function, taken from the
> doucmentation:
>
>-- Function: sum_n_product(integer, integer)
>-- DROP FUNCTION sum_n_product(integer, integer);
>CREATE OR REPLACE FUNCTION sum_n_product(IN x integer, IN y integer,
> OUT sum integer, OUT prod integer) RETURNS record AS
>$BODY$
>BEGIN
> sum := x + y;
> prod := x * y;
>END;
>$BODY$
> LANGUAGE 'plpgsql' VOLATILE;
>
>If I go to a query window and execute "select sum_n_product(2, 3)", I
> get back "(2,3)". I then wrote a function named "test_sum_n_product"
> to try to retrieve one of the numbers from inside the record (or
> whatever it is) that sum_n_product gave me.
Hint 1: SELECT * FROM sum_n_product(2, 3);
Hint 2: SELECT * FROM sum_n_product(2, 3) INTO foo;
--
Leif Biberg Kristensen | Registered Linux User #338009
Me And My Database: http://solumslekt.org/blog/
From | Date | Subject | |
---|---|---|---|
Next Message | William Temperley | 2009-06-04 12:35:17 | Re: High I/O writes activity on disks causing images on browser to lag and not load |
Previous Message | Carlos Oliva | 2009-06-04 12:23:23 | Re: Upgrading Database: need to dump and restore? |