BEGIN
EXECUTE IMMEDIATE 'CREATE OR REPLACE VIEW VHEADS
    AS
        SELECT  E.ID AS ID, E.NAME AS NAME, EH.ID AS HEADID, EH.NAME AS HEADNAME FROM EMPLOYEE E 
        INNER JOIN VSTRUCTDIVISIONPARENTSANDTHIS VSP ON E.STRUCTDIVISIONID = VSP.ID
        INNER JOIN EMPLOYEE EH ON EH.STRUCTDIVISIONID = VSP.PARENTID AND EH.ISHEAD = 1';
END;