public function updateRecord($recArr, $oldRecord = null)
    {
        $this->events()->trigger(__FUNCTION__ . '.pre', $this, array('record' => $recArr, 'old_record' => $oldRecord));
        if (!$this->canUpdateRecord($oldRecord)) {
            $this->errorMessage = MessageHelper::getMessage("DATA_NO_PERMISSION_UPDATE", $this->objectName);
            throw new Openbizx\Data\Exception($this->errorMessage);
            return false;
        }

        if (!$oldRecord)
            $oldRecord = $this->getActiveRecord();

        if (!$recArr["Id"])
            $recArr["Id"] = $this->getFieldValue("Id");

        // save the old values
        $this->bizRecord->saveOldRecord($oldRecord);
        // set the new values
        $this->bizRecord->setInputRecord($recArr);

        if (!$this->validateInput())
            return false;

        $sql = $this->getSQLHelper()->buildUpdateSQL($this);

        if ($sql) {
            $db = $this->getDBConnection("WRITE");
            if ($this->useTransaction)
                $db->beginTransaction();

            try {
                $this->cascadeUpdate(); // cascade update

                Openbizx::$app->getLog()->log(LOG_DEBUG, "DATAOBJ", "Update Sql = $sql");
                $db->query($sql);

                if ($this->useTransaction)
                    $db->commit();
            } catch (Exception $e) {
                if ($this->useTransaction)
                    $db->rollBack();

                if ($e instanceof Openbizx\Data\Exception)
                    throw $e;
                else {
                    Openbizx::$app->getLog()->log(LOG_ERR, "DATAOBJ", "Query error : " . $e->getMessage());
                    $this->errorMessage = $this->getMessage("DATA_ERROR_QUERY") . ": " . $sql . ". " . $e->getMessage();
                    throw new Openbizx\Data\Exception($this->errorMessage);
                }
                return false;
            }

            $this->cleanCache(); //clean cached data
            $this->_postUpdateLobFields($recArr);
            $this->currentRecord = null;
            $this->_postUpdateRecord($recArr);
        }
        $this->events()->trigger(__FUNCTION__ . '.post', $this, array('record' => $recArr, 'old_record' => $oldRecord));
        return true;
    }