function createAggregate($name, $basetype, $sfunc, $stype, $ffunc, $initcond, $sortop, $comment)
{
$f_schema = $this->_schema;
$this->fieldClean($f_schema);
$this->fieldClean($name);
$this->fieldClean($basetype);
$this->fieldClean($sfunc);
$this->fieldClean($stype);
$this->fieldClean($ffunc);
$this->fieldClean($initcond);
$this->fieldClean($sortop);
$this->beginTransaction();
$sql = "CREATE AGGREGATE \"{$f_schema}\".\"{$name}\" (BASETYPE = \"{$basetype}\", SFUNC = \"{$sfunc}\", STYPE = \"{$stype}\"";
if (trim($ffunc) != '') {
$sql .= ", FINALFUNC = \"{$ffunc}\"";
}
if (trim($initcond) != '') {
$sql .= ", INITCOND = \"{$initcond}\"";
}
if (trim($sortop) != '') {
$sql .= ", SORTOP = \"{$sortop}\"";
}
$sql .= ")";
$status = $this->execute($sql);
if ($status) {
$this->rollbackTransaction();
return -1;
}
if (trim($comment) != '') {
$status = $this->setComment('AGGREGATE', $name, '', $comment, $basetype);
if ($status) {
$this->rollbackTransaction();
return -1;
}
}
return $this->endTransaction();
}