@echo Set up function NODE_GOOD⠒TR_B_IU_R; set search_path = snowrunner, public; create or replace function NODE_GOOD⠒TR_B_IU_R() returns trigger language plpgsql stable as $body$ declare -- V⠒NODE_TYPE⠒NAME text; V⠒NODE_TYPE⠒NAME NODE⠒V.NODE_TYPE⠒NAME%type := null; begin select NODE_TYPE⠒NAME into V⠒NODE_TYPE⠒NAME from NODE⠒V where 1 = 1 and ID = new.NODE⠒ID and 1 = 1; if ( V⠒NODE_TYPE⠒NAME = 'Drop-off' and new.TASK_NAME is null) then raise exception 'A good connection to a drop-off node must have a task name!'; elsif ( V⠒NODE_TYPE⠒NAME != 'Drop-off' and new.TASK_NAME is not null) then raise exception 'A good connection to a non-drop-off node cannot have a task name!'; end if; return null; end; $body$; commit;