CREATE OR REPLACE TRIGGER olaf_author_trg
	AFTER INSERT OR UPDATE ON FABIAN_DATA
	FOR EACH ROW
	DECLARE
		VTagtype fabian_tag.id%type;
		VArticleID fabian_tag.id%type;
		VPos fabian_attr.value%type;
	BEGIN
		select name into VTagtype from fabian_tag where id=:new.tagid;
		if (VTagtype = 'author') then
			select value into VPos from fabian_attr where name='position' and tagid = :new.tagid;
			if (VPos = '00') then 
				select parent into VArticleID from fabian_ptr where child in (select parent from fabian_ptr where child=:new.tagid);		
			update fabian_art set author=:new.data where articleid=VArticleID;
			end if;
		end if;
	END;
/
