function cancellaDB(IDcentralina,DTcatena,Data_scarico,FileName,conn)

fileID = fopen(FileName,'a');
fmt = '%s \r';
text = 'cancellaDB function started';
fprintf(fileID,fmt,text);

comando = ['delete from ELABDATADISP where UnitName = ''' IDcentralina...
    ''' and ToolNameID = ''' DTcatena ''' and EventDate >= ''' Data_scarico ''' '];

curs = exec(conn,comando);

text = strcat('Elaborated Data of Unit ', IDcentralina, ' Chain ',...
    DTcatena,' deleted starting from date ',Data_scarico,' during the execution of LastElab function.');
fprintf(fileID,fmt,text);

text = 'cancellaDB function ended';
fprintf(fileID,fmt,text);
fclose(fileID);
        
end