#
#		ITSV GmbH
#		CCDB - Command and Control Database
#
#		FILE:			dquerymfile_markMAFILEStoreconv.txt
#		DESCRIPTION:	DQUERY definition for markMAFILEStoreconv
#						marks all managed file of type 'dmvbrfausw' to be re-converted, by setting attribute 'to_reconvert' to 'true'
#
@querytitle				Alle 'Auswertung_MeldungenClearingfaelle'-mananged files als zu re-konvertieren markieren
@querydescription		Markiert alle managed files des MFILETYP 'dmvbrfausw' als zu re-konvertieren, in dem das Attribut 'to_reconvert' auf 'true' gesetzt wird
@group					SVCLMVBRFAUSWDATALOAD
@querytype				function
@function				seqtrans.seqtrans
@sql_select				select MFILEID,MFILETYPE,MFILEATTRIBS from CCMFILES where MFILETYPE='dmvbrfausw'

~query.tsteps

#
# 0: initialize
#
qexpression
	proc: {
		if (!this.init_done) {
			this.protocol = new Array();
			this.filestoprocess = this.inputresult.getRowCount();
			this.filesprocessed = 0;
			this.qname = this.query.dataname;
			this.fpfx = this.fname+"("+this.qname+")";
			this.protocol.push([this.fpfx+"_STARTED","FILESTOPROCESS="+this.filestoprocess,"",""]);
			this.init_done = true;
		}
		copycvars(this,"MFILEID,MFILETYPE,MFILEATTRIBS");
	}

#
# 1: update one CCMFILES entry
#
pre_qexpression
	this.mfileattributes = JSON.parse(this.MFILEATTRIBS);
	this.mfileattributes.to_reconvert = true;
	this.cdata.MFILEATTRIBS = JSON.stringify(this.mfileattributes);
sql				update CCMFILES set MFILEATTRIBS=::MFILEATTRIBS:: where MFILEID=::MFILEID::
named_params	MFILEID,MFILEATTRIBS
result_varname	updres
post_qexpression
	this.filesprocessed++;
	this.protocol.push([this.fpfx+"_FILE_PROCESSED","RECORD="+this.recnum,"MFILEID="+this.MFILEID,"UPDATE_RESULT="+aux.objTxt(this.updres)]);
	
#
# 2: file processed, check if last record
#
if (!this.is_last_record)
goto done

#
# 3: last record, protocl summary record
#
qexpression
	this.protocol.push([this.fpfx+"_FINISHED","FILES_PROCESSED="+this.filesprocessed,"",""]);
	
#
# 4: done
#
done:
end
	