#
#		ITSV GmbH
#	CCDB - Command and Control Database
#
#	FILE:			dquerymfile_LOADSVCLUSPPERS.txt
#	DESCRIPTION:	DQUERY definition for DQUERY LOADSVCLUSPPERS
#					loads USP user parameters from CSV file to table SVCLUSPPERS
#
@querytitle					USP-KUR-Personen-Daten aus Datei laden
@querydescription			lädt Daten aus einer CSV-Datei in die Tabelle SVCLUSPPERS
@group						SVCLCASETOOLS
@attributenames				mfileid:mfileid
@querytype					function
@function					seqtrans.seqtrans
@FFHLIST					KUR;Verfahren;Verfahrensrecht;Fremdbereich;BPK
@FLIST						KUR,VERFAHREN,VERFAHRENSRECHT,FREMDBEREICH,SVBPKVER
@TABNAME					SVCLUSPPERS

~query.tsteps

#
# <<TSTEPNUM:0>>: determine if init to be done
#
if			(this.init_done)
goto		record_proper

#
# <<TSTEPNUM:1>>: create table if not yet there
#
pre_qexpression
		this.query.FPLIST = "::" + this.query.FLIST.split(",").join("::,::") + "::";
		this.query.FFLIST = this.query.FFHLIST.split(";").join(",");	
sql 	create table if not exists @@TABNAME@@ (KUR varchar(32), VERFAHREN varchar(32), VERFAHRENSRECHT varchar(255), FREMDBEREICH varchar(32), SVBPKVER varchar(255))
post_qexpression
			this.recstoprocess = this.inputresult.getRecordCount();
			this.recordsprocessed = 0;
			this.ppush([this.phead("STARTING"),"STARTTIME="+aux.nowsvtime(),"RECSTOPROCESS="+this.recstoprocess,""]);

#
# <<TSTEPNUM:2>>: insert one record_proper
#
record_proper:
sql			insert into @@TABNAME@@(@@FLIST@@) values(@@FPLIST@@)
post_qexpression
		this.recsprocessed++;

#
# <<TSTEPNUM:3>>: check if last record
#
if		(!this.is_last_record)
goto	record_end

#
# <<TSTEPNUM:4>>: terminate protocol
#
qexpression
		this.ppush([this.phead("FINISHED),"ENDTIME=="+aux.nowsvtime(),"RECSPROCESSED="+this.recsprocessed,""]);

#
# <<TSTEPNUM:5>>: end of processing
#
record_end:
end