# # ITSV GmbH # CCDB - Command and Control DAtabase # # FILE: dquerymfile_loadgemeinderw.txt # DESCRIPTION: DQUERY definition for DQUERY loadgemeinderw # this DQUERY loads a managed file into the table CCRWGEMEINDE # @querytitle Managed file in Regelwerkstabelle CCRWGEMEINDE laden @querydescription lädt den inhalt einer managed Datei in die Regelwerks-Tabelle CCRWGEMEINDE @group ADMIN @attributenames mfileid:mfileid:{{mfileidoptions}} # # NOTE: input data for the transaction sequence is taken from the managed file named in query attribute # @mfileidoptions {"labeltext":"managed Datei","typedesc":"ID der managed Datei, die in die Tabelle CCRWGEMEINDE geladen werden soll"} @querytype function @function seqtrans.seqtrans @FLIST GEMEINDEKENNZIFFER, GEMEINDENAME, GEMEINDECODE, STATUS, PLZ_GEM_AMT, WEITERE_PLZ @FSIZELIST 5, 255, 5, 3, 4, 255 @input_options.startline 3 @input_options.headersInFirstLine 0 @input_encoding ISO8859-1 @init.qexpression this.REXLIST = [ /^[0-9]{5}$/, /^.+$/, /^[0-9]{5}$/, /^[A-Z]{0,2}$/, /^[0-9]{4}$/, /^([0-9]{4}\s*)*$/ ]; this.load_file = load_file; this.query.input_options.colnames = new Array(); this.fieldsizes = this.query.FSIZELIST.split(","); for (let i=0; i>: check for initialize # if (this.init_ok) goto init_done # # <>: init: drop table # sql drop table if exists CCRWGEMEINDE result_varname dropres post_qexpression this.ppush([this.phead("RWTABDROPPED"),"","",this.dropres]); # # <>: init: create table # pre_qexpression this.cclause = ""; for (let i=0; i0) this.cclause += ","; this.cclause += this.fieldnames[i] + " varchar("+this.fieldsizes[i] + ")"; } sql create table CCRWGEMEINDE(@@cclause@@) result_varname creres post_qexpression this.ppush([this.phead("RWTABCREATED"),"","",this.creres]); # # <>: init complete # qexpression this.init_ok = true; # # <>: init done # init_done: noop # # <>: check record structure and skip inserting if not good # pre_qexpression this.ok = true; let rp = new Array(); proc: { let m; let fn; for (let ci=0; ci>: insert record # sql insert into CCRWGEMEINDE(@@FLIST@@) values(@@FTLIST@@) named_params @@FLIST@@ result_varname insres post_qexpression this.recordsinserted++; # # <>: check if last recordsinserted # record_skipped: pre_qexpression this.recordsprocessed++; if (!this.is_last_record) goto rec_end # # <>: close protocol # qexpression this.ppush([this.phead("FINISHED"),"RECORDS_PROCESSED="+this.recordsprocessed,"RECORDSINSERTED="+this.recordsinserted,"RECORDS_SKIPPED="+this.recordsskipped]); # # <>: end of record # rec_end: end