#
#	action sequence for object action setGroupAttribute
#

#
# prepare action
#
qexpression
	copycvars(this,"action,objtype,attribute,key,value");
	this.valid_fieldnames = {	GRPID:			{},
								GRPNAME:		{},
								PARENTGRPID:	{},
								GRPDESC:		{},
								GRPURL:			{} };
	if (!this.valid_fieldnames[this.attribute]) {
		this.errcoll.collect(null,"invalid attribute name \""+this.attribute+"\" for setGroupAttribute",this.cdata);
	}

#
# check if group is in database
#
sql 			select GRPID,GRPNAME,PARENTGRPID,GRPDESC,GRPURL from CCGRP where GRPID=::key::
named_params	key	
result_varname	rcres

#
# if not there, bail out
#
if (this.rcres.getRowCount()==1)
goto do_update

#
# signal error group not found
#
qexpression		this.errcoll.collect(null,"Group \""+this.key+"\" not found for setGroupAttribute",this.cdata);

#
# terminate
#
goto done

#
# perform the database update
#
do_update:
pre_qexpression	this.updsql = "update CCGRP set "+this.attribute+"=::value:: WHERE GRPID=::key::"
sql_varname		updsql
named_params	key,value

#
# complete
#
done:
qexpression		logger.debug("setGroupAttribute.complete");

#
# finally, set chain query to re-display group info after having performed the action
#
done:
qexpression this.query.chain_query = {dataname: "groupinfo", grpid: this.key};