From: | Rémi Cura <remi(dot)cura(at)gmail(dot)com> |
---|---|
To: | PostgreSQL General <pgsql-general(at)postgresql(dot)org> |
Subject: | update several columns from function returning several values |
Date: | 2014-12-02 16:15:00 |
Message-ID: | CAJvUf_t-V5OwJeE3ga5saFfMTAFdz6DpCA3gXv4cREyxqVsrvg@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Hey,
a trivial question I guess,
can't make it work.
IF I define a function returning several values , I can't use it to update
mutliple columns of a table at once.
i __don't__ want to use CTE or subquerry,
and of course I don't wan tto compute the function several time.
CREATE TABLE test_update_m_values (
gid int,
gid_plus_1 int,
gid_minus_1 int
);
INSERT INTO test_update_m_values VALUES (1,0,0) ;
CREATE OR REPLACE FUNCTION rc_test_update_m_values( gid int,OUT gid_plus_1
int, OUT gid_minus_1 int)
AS $$ -- @brief : test function, can be deleted
BEGIN
SELECT gid+1,gid-1 INTO gid_plus_1, gid_minus_1;
RETURN ;
END;
$$ LANGUAGE 'plpgsql' IMMUTABLE STRICT ;
UPDATE test_update_m_values SET (gid_plus_1,gid_minus_1) =
(rc_test_update_m_values(gid)); --doesn't work
Somebody now if this is possible?
CHeers,
Rémi-C
From | Date | Subject | |
---|---|---|---|
Next Message | Melvin Davidson | 2014-12-02 16:16:24 | Re: Programmatic access to interval units |
Previous Message | Dave Rosckes | 2014-12-02 16:10:05 | Trying to get SSPI/JDBC working |