#
#	ITSV GmbH
#	CCDB - Command and Control Database
#	FILE:			objact_dropLSW
#	DESCRIPTION:	action sequence for object action dropLSW

#
# 0: determine SQL statement and key values
#
qexpression
	proc: {
		copycvars(this,"action,objtype,attribute,key,value");
	}

#
# 1: check if there are SOIDs linked to out LSW by the LSWID
#
sql				select * from SVCLRWSOID where LSWID=::key::
named_params	key
result_varname	soidres
post_qexpression
	if (this.soidres.getRowCount()>0) {
		this.errcoll.collect(null,"Cannot delete LSW with LSWID=\""+this.key+"\", there are SOIDs linked to it",this.soidres);
	}

#
# 2: delete the SVCLRWLSW entry
#
sql				delete from SVCLRWLSW where LSWID=::key::
named_params	key

#
# 3: finally, set chain query to re-display the complete LSWEDITOR or the query we were triggered from ("return_to")
#
done:
qexpression 
	if (this.query.return_to) {
		this.query.chain_query = {dataname: this.query.return_to};
	} else {
		this.query.chain_query = {dataname: "LSWEDITOR"};
	}