Я использую PostgreSQL 9.1 с PostGIS 1.5.
Я пытаюсь заставить эту триггерную функцию работать в терминале (Ubuntu):
CREATE FUNCTION insert_trigger()
RETURNS trigger AS
$insert_trigger$
BEGIN
IF ( NEW.id >= 10 AND NEW.id < 100 ) THEN
INSERT INTO part_id_p10 VALUES (NEW.*);
ELSIF ( NEW.id >= 100 AND NEW.id < 200 ) THEN
INSERT INTO part_id_p20 VALUES (NEW.*);
ELSE
RAISE EXCEPTION 'id out of range. Something wrong with the insert_trigger() function!';
END IF;
RETURN NULL;
END
$insert_trigger$ LANGUAGE plpgsql;
Я получаю следующие исключения:
SQLException: ERROR: Encountered "FUNCTION" at line 1, column 8.
SQLException: ERROR: Encountered "ELSIF" at line 1, column 1.
SQLException: ERROR: Encountered "ELSE" at line 1, column 1.
SQLException: Cannot commit when autoCommit is enabled.
SQLException: ERROR: Encountered "RETURN" at line 1, column 1.
SQLException: Cannot commit when autoCommit is enabled.