#
#		ITSV GmbH
#	CCDB - Command and Control Database
#
#	FILE:		dquermfile_kfodelreport.txt
#	DESCRIPTION:	DQUERY definition for CCDB DQUERY "kfodelreport"
#
@querytitle
		Eine Auswertung löschen
@querydescription
		
@group	KFOQSDBREP
@attributenames	cfgname:kfodbconfigname,repid:string:{{repidoptions}}
@repidoptions	{"labeltext":"Auswertungs-ID","typedesc":"ID der Auswertung in der KFOQSDB {{cfgname}}"}
@querytype		function
@function		seqtrans.seqtrans
@init.qexpression
	let ids = this.query.repid.split(",");
	this.inputresult = new aux.Result("dbresult");
	this.inputresult.addColumn("repid");
	for (let i=0; i<ids.length; i++) {
		this.inputresult.addRow([ids[i]]);
	}
@setup.qexpression
	this.cfgname = this.query.cfgname;

~query.tsteps

#
# <<TSTEPNUM:0>>: delete any referencing Benachrichtigung-records
#
sql				delete from "Benachrichtigung" where "AuswertungId"=::repid::
named_params	repid
cfgname			@@cfgname@@
result_varname	delnres
post_qexpression
	this.ppush([this.phead("NOTIFDELETED"),"Benachrichtigung(en) gelöscht","ID="+this.cdata.repid,this.delnres]);

#
# <<TSTEPNUM:1>>: delete one Auswertung-record
#
sql				delete from "Auswertung" where "ID"=::repid::
named_params	repid
cfgname			@@cfgname@@
result_varname	delres
post_qexpression
	this.ppush([this.phead("REPDELETED"),"Auswertung gelöscht","ID="+this.cdata.repid,this.delres]);