#
#	DQUERY configuration for "delkfoanspmfiles"
#
#	this query shall delete all managed file of type genxls with KFOASNP in their attributes
#
@group		KFOQSDBANSP
#
# querytype "qprog" tells there is a query-program to be executed
#
@querytype	qprog
#
# resultobject_options.expandall instructs web renderer to expand all hierarchical object levels upon rendering
#
@resultobject_options.expandall true
#
# the query-program is to be provided as a javascript-fragment defining the query program
#
@queryprogram	queryprogram = this.queryprogram;

~queryprogram.program

#
# 0:
#
query.querytype				dbselect
query.format				none
query.sql					select MFILEID from CCMFILES where MFILETYPE='genxls' and MFILEATTRIBS like '%kfoansp%'

#
# 1:
#
cmd							jsexpr
expression	
	if (!this.result) {
		logger.debug("no this.result");
		this.errcoll.collect(null,"no this.result");
		aux.error_callback(this.callback,null,"no this.result");
	}
	this.recs2process = this.result.getRowCount();
	this.recsprocessed = 0;
	this.curprocrecord = 0;
	this.inputresult = this.result;
	this.inputresult.setResultAttribute('title','zu löschende MFILEs');
	this.inputresult.setResultAttribute('bottomtext',this.recs2process+' MFILEs zu löschen');
	this.results = new Array();
	this.result.push(this.inputresult);

#
# 2:
#
label	next_record
if		(this.recs2process<1)
goto	done

#
# 3:
#
expression		this.curmfile2delete = this.inputresult.getCellValue(this.curprocrecord,0);

#
# 4:
#
query.dataname				DELMFILE
query.mfileid				{{curmfile2delete}}

#
# 5:
#
expression
	this.results.push(this.result);
	this.recsprocessed++;
	this.curprocrecord++;
	this.recs2process--;
	
#
# 6:
#
goto	next_record

#
# 7:
#
label	done
expression
	this.sumres = new aux.Result('plain');
	this.sumres.body = this.recsprocessed + ' MFILEs gelöscht';
	this.results.push(this.sumres);
