# # # ITSV GmbH # CCDB - Command and Control Database # # FILE: dquerymfile_loadRWfromMFILE # DESCRIPTION: DQUERY definition file for DQUERY loadRWfromMFILE # this query loads one specific Regelwerk from an MFILE into CCRW # @querytitle Ein Regelwerk aus einer Datei laden @querydescription lädt ein definiertes Regelwerk der CCDB aus einem managed file @group RWDATA @attributenames mfileid:mfileid,rwid:rwid @querytype function @function seqtrans.seqtrans @FLIST RWTYP,RWPARENT,RWNAME,RWVALUE,RWDESC @init.qexpression this.valid_rws = { QUERIES: { rwtypes: [ "DQUERY","DQUERYPARAM" ] }, TYPES: { rwtypes: [ "TYPE","TYPEATTRIB" ] }, OBJTYPES: { rwtypes: [ "OBJTYPE","OBJACTION","OACTION","OACTATTRIB" ] } } ~query.tsteps # # <>: if already initialized, skip run-once initialization steps # pre_qexpression copycvars(this,this.query.FLIST); if (this.init_done) goto record_proper # # <>: initialization # qexpression proc: { this.ppfx = this.fname+"("+this.dataname+")"; this.FLIST = this.query.FLIST; this.IFNAMES = this.FLIST.split(","); this.TPLIST = "::" + this.IFNAMES.join("::,::") + "::"; this.cns = {}; let cn; for (let ci=0; ci>: remove old RW contents # pre_qexpression this.remove_sql = "DELETE from CCRW where RWTYP in ('"+this.rwdesc.rwtypes.join("','")+"')"; sql @@remove_sql@@ result_varname remres post_qexpression ppush(this,[this.ppfx+"_OLD_REMOVED","ROWS_AFFECTED="+this.remres.resultobject.affectedRows,"DB_MESSAGE="+this.remres.resultobject.message,"REMOVE_SQL=\""+this.remove_sql+"\""]); this.init_done = true; # # <>: check if current record shall be inserted # record_proper: pre_qexpression logger.debug("RECNUM="+this.recnum+".RWTYP="+this.RWTYP+".RWTS="+aux.objTxt(this.rwdesc.rwts)); if (!(this.rwdesc.rwts[this.RWTYP] && this.rwdesc.rwts[this.RWTYP].load_record)) goto skip_record # # <>: load current record in CCRW # sql INSERT INTO CCRW(@@FLIST@@) values(@@TPLIST@@) named_params @@FLIST@@ result_varname insres post_qexpression if (this.insres.resultobject.affectedRows!=1) { this.errcoll.collect(null,"insert into CCRW affected wrong number of rows",this.insres); } else { this.recsloaded += this.insres.resultobject.affectedRows; } # # <>: check if last record # skip_record: pre_qexpression this.recsprocessed++; if (!this.is_last_record) goto done # # <>: last record, close off protocol # qexpression ppush(this,[this.ppfx+"_FINISHED","RECSTOPROCESS="+this.recstoprocess,"RECSPROCESSED="+this.recsprocessed,"RECSLOADED="+this.recsloaded]); # # <>: end of record # done: end