And when I try to create a trigger:
CREATE TRIGGER ctg_el_del
AFTER DELETE ON ctg
FOR EACH ROW
BEGIN
DELETE FROM ctg
where ctg.id_ctg = old.lft
STEP 1 : You need to Create function that returns type Trigger in that function you should mention the SQL Operation like below:
CREATE FUNCTION trigger_function() RETURNS TRIGGER AS $$
BEGIN
DELETE FROM ctg
WHERE ctg.id_ctg = old.lft
AND ctg.id_ctg = old.rgt;
END
$$
LANGUAGE plpgsql;
STEP 2 : And then create the trigger on the table to call after delete like this:
CREATE TRIGGER ctg_el_del
AFTER DELETE ON ctg
FOR EACH ROW
EXECUTE PROCEDURE trigger_function();