Witam,
Musze napisac funkcje
, ktora bedzie wywolywana przez trigger
.
CREATE OR REPLACE FUNCTION deal_update() RETURNS trigger AS
$$
BEGIN
SELECT id, lower(time_range), upper(time_range)
FROM deal
WHERE (lower(time_range) IS NULL OR upper(time_range) IS NULL )
AND id = OLD.id;
IF FOUND THEN
RAISE EXCEPTION 'test';
END IF;
UPDATE deal
SET time_range = tstzrange(lower(time_range), current_timestamp)
WHERE id = OLD.id;
RETURN NULL;
END;
$$
LANGUAGE plpgsql;
Powyzsza funkcja rzuca blad:
[42601] ERROR: query has no destination for result data Hint: If you want to discard the results of a SELECT, use PERFORM instead. Where: PL/pgSQL function deal_update() line 5 at SQL statement