DROP FUNCTION if exists sp_Prof_Delete(uuid);
CREATE OR REPLACE FUNCTION sp_Prof_Delete
(
    "FileID" uuid
)
RETURNS void
LANGUAGE plpgsql
AS $function$
begin
    DELETE FROM ISZL.T_DISP_DIRECT dd
    WHERE dd.DispDirectFile = "FileID"
        and dd.type_ = (select e.EntityID from VCLib.T_ENTITIES e where e.EntName = 'DISP_DIRECT' limit 1);

    DELETE FROM ISZL.T_DISP_DIRECT_FILE WHERE FileId = "FileID";

    DELETE FROM VCLib.T_FILE WHERE FileId = "FileID";
end;
$function$;
