Ist es möglich, auf den aktuellen Datensatz innerhalb einer Update-Anweisung zu verweisen/zuzugreifen/ihn zu übergeben?Zugriff auf den gesamten aktuellen Datensatz innerhalb der Update-Anweisung
CREATE TABLE t1 (
id serial PRIMARY KEY,
name text
);
CREATE TABLE t2 (
id serial PRIMARY KEY,
name text,
foo text
);
CREATE FUNCTION gen_t2_foo(_a t1, _b t2) RETURNS text AS $$
SELECT _a.name || ' - ' || _b.name;
$$ LANGUAGE sql;
CREATE FUNCTION upd_t2(_min_id int, _max_id int, _a t1) RETURNS VOID AS $$
UPDATE t2 SET
foo = gen_f2_name(_a, ???) -- How to pass the current t2 record?
WHERE id >= _min_id AND id <= _max_id;
$$ LANGUAGE sql;
Uh, thanks man! – hooblei
... oder innerhalb eines Schemas mit einem Alias 'UPDATE s1.t1 r SET foo = gen_t2_foo (_a, r) ...' – hooblei