CREATE OR REPLACE FUNCTION msgfailerror() RETURNS trigger AS
\' BEGIN
IF NEW.noces< new.first_column THEN
RAISE EXCEPTION \'cannot have a negative sala
The quoting is wrong. It's easier to use dollar quotes $$:
CREATE OR REPLACE FUNCTION msgfailerror()
RETURNS trigger AS
$$
BEGIN
IF NEW.noces< new.first_column THEN
RAISE EXCEPTION 'cannot have a negative salary';
END IF;
return new;
END;
$$
LANGUAGE plpgsql;
But on the other hand, what's wrong with a check constraint?