pl/pgsql NEW variable substitution - Mailing list pgsql-general

From jef peeraer
Subject pl/pgsql NEW variable substitution
Date
Msg-id 451A4F8E.3040804@telenet.be
Whole thread Raw
Responses Re: pl/pgsql NEW variable substitution
List pgsql-general
i want to check in a trigger if certain columns are not left empty. The
columns i have to check are stored in another table. How do i do the
following

BEGIN
    SELECT INTO col_record * FROM modules WHERE type_module_id =
NEW.type_module_id AND is_afsluit_kolom;
    IF NOT FOUND THEN
        RAISE EXCEPTION 'geen afsluitkolom gedefinieerd voor type_module % ',
NEW.type_module_id;
    ELSE
        col_naam := col_record.kolom_naam;
        RAISE NOTICE 'kolom to check is % ', col_naam;
        --- check if afsluitrecord is empty
        IF NEW.col_naam != '' THEN
            RETURN NEW;
        ELSE
            RAISE EXCEPTION 'dit record is afgesloten voor wijzigingen !';
        END IF;
      END IF;
END;


I want col_naam to be evaluated before used with NEW . Now i get a
warning that the table the trigger is written for doesn't has a column
'col_naam'.


jef peeraer

pgsql-general by date:

Previous
From: Alban Hertroys
Date:
Subject: Re: postgresql ddl scripts - drop object fails entire script
Next
From: Alban Hertroys
Date:
Subject: reply-to address broken (Was: Re: postgresql ddl scripts - drop object fails entire script)