Replace a fact with a new gedcom data.

@param string $fact_id
@param string $gedcom
@param bool   $update_chan

@return void
@throws Exception
428007
public function updateFact(string $fact_id, string $gedcom, bool $update_chan): void
    {
        // MSDOS line endings will break things in horrible ways
        $gedcom = preg_replace('/[\r\n]+/', "\n", $gedcom);
        $gedcom = trim($gedcom);

        if ($this->pending === '') {
            throw new Exception('Cannot edit a deleted record');
        }
        if ($gedcom !== '' && !preg_match('/^1 ' . Gedcom::REGEX_TAG . '/', $gedcom)) {
            throw new Exception('Invalid GEDCOM data passed to GedcomRecord::updateFact(' . $gedcom . ')');
        }

        if ($this->pending) {
            $old_gedcom = $this->pending;
        } else {
            $old_gedcom = $this->gedcom;
        }

        // First line of record may contain data - e.g. NOTE records.
        [$new_gedcom] = explode("\n", $old_gedcom, 2);

        // Replacing (or deleting) an existing fact
        foreach ($this->facts([], false, Auth::PRIV_HIDE) as $fact) {
            if (!$fact->isPendingDeletion()) {
                if ($fact->id() === $fact_id) {
                    if ($gedcom !== '') {
                        $new_gedcom .= "\n" . $gedcom;
                    }
                    $fact_id = 'NOT A VALID FACT ID'; // Only replace/delete one copy of a duplicate fact
                } elseif ($fact->getTag() !== 'CHAN' || !$update_chan) {
                    $new_gedcom .= "\n" . $fact->gedcom();
                }
            }
        }
        if ($update_chan) {
            $new_gedcom .= "\n1 CHAN\n2 DATE " . strtoupper(date('d M Y')) . "\n3 TIME " . date('H:i:s') . "\n2 _WT_USER " . Auth::user()->userName();
        }

        // Adding a new fact
        if ($fact_id === '') {
            $new_gedcom .= "\n" . $gedcom;
        }

        if ($new_gedcom !== $old_gedcom) {
            // Save the changes
            DB::table('change')->insert([
                'gedcom_id'  => $this->tree->id(),
                'xref'       => $this->xref,
                'old_gedcom' => $old_gedcom,
                'new_gedcom' => $new_gedcom,
                'user_id'    => Auth::id(),
            ]);

            $this->pending = $new_gedcom;

            if (Auth::user()->getPreference('auto_accept')) {
                FunctionsImport::acceptAllChanges($this->xref, $this->tree);
                $this->gedcom  = $new_gedcom;
                $this->pending = null;
            }
        }
        $this->parseFacts();
    }
714388
public function editRawFact(ServerRequestInterface $request, Tree $tree): ResponseInterface
    {
        $xref    = $request->get('xref', '');
        $fact_id = $request->get('fact_id');
        $record  = GedcomRecord::getInstance($xref, $tree);

        Auth::checkRecordAccess($record, true);

        $title = I18N::translate('Edit the raw GEDCOM') . ' - ' . $record->fullName();

        foreach ($record->facts() as $fact) {
            if (!$fact->isPendingDeletion() && $fact->id() === $fact_id) {
                return $this->viewResponse('edit/raw-gedcom-fact', [
                    'pattern' => self::GEDCOM_FACT_REGEX,
                    'fact'    => $fact,
                    'title'   => $title,
                ]);
            }
        }

        return redirect($record->url());
    }
234753
public static function printMainSources(Fact $fact, int $level): void
    {
        $factrec = $fact->gedcom();
        $parent  = $fact->record();
        $tree    = $fact->record()->tree();

        $nlevel = $level + 1;
        if ($fact->isPendingAddition()) {
            $styleadd = 'wt-new';
            $can_edit = $level === 1 && $fact->canEdit();
        } elseif ($fact->isPendingDeletion()) {
            $styleadd = 'wt-old';
            $can_edit = false;
        } else {
            $styleadd = '';
            $can_edit = $level === 1 && $fact->canEdit();
        }

        // -- find source for each fact
        $ct    = preg_match_all("/($level SOUR (.+))/", $factrec, $match, PREG_SET_ORDER);
        $spos2 = 0;
        for ($j = 0; $j < $ct; $j++) {
            $sid   = trim($match[$j][2], '@');
            $spos1 = strpos($factrec, $match[$j][1], $spos2);
            $spos2 = strpos($factrec, "\n$level", $spos1);
            if (!$spos2) {
                $spos2 = strlen($factrec);
            }
            $srec   = substr($factrec, $spos1, $spos2 - $spos1);
            $source = Source::getInstance($sid, $tree);
            // Allow access to "1 SOUR @non_existent_source@", so it can be corrected/deleted
            if (!$source || $source->canShow()) {
                if ($level > 1) {
                    echo '<tr class="wt-level-two-source collapse">';
                } else {
                    echo '<tr>';
                }
                echo '<th class="';
                if ($level > 1) {
                    echo ' rela';
                }
                echo ' ', $styleadd, '">';
                $factlines = explode("\n", $factrec); // 1 BIRT Y\n2 SOUR ...
                $factwords = explode(' ', $factlines[0]); // 1 BIRT Y
                $factname  = $factwords[1]; // BIRT
                if ($factname === 'EVEN' || $factname === 'FACT') {
                    // Add ' EVEN' to provide sensible output for an event with an empty TYPE record
                    $ct = preg_match('/2 TYPE (.*)/', $factrec, $ematch);
                    if ($ct > 0) {
                        $factname = trim($ematch[1]);
                        echo $factname;
                    } else {
                        echo GedcomTag::getLabel($factname, $parent);
                    }
                } elseif ($can_edit) {
                    echo '<a href="' . e(route('edit-fact', [
                            'xref'    => $parent->xref(),
                            'fact_id' => $fact->id(),
                            'ged'     => $tree->name(),
                        ])) . '" title="', I18N::translate('Edit'), '">';
                    if ($tree->getPreference('SHOW_FACT_ICONS') && $level === 1) {
                        echo '<i class="icon-source"></i> ';
                    }
                    echo GedcomTag::getLabel($factname, $parent), '</a>';
                    echo '<div class="editfacts">';
                    if (preg_match('/^@.+@$/', $match[$j][2])) {
                        // Inline sources can't be edited. Attempting to save one will convert it
                        // into a link, and delete it.
                        // e.g. "1 SOUR my source" becomes "1 SOUR @my source@" which does not exist.
                        echo view('edit/icon-fact-edit', ['fact' => $fact]);
                        echo view('edit/icon-fact-copy', ['fact' => $fact]);
                    }
                    echo view('edit/icon-fact-delete', ['fact' => $fact]);
                } else {
                    echo GedcomTag::getLabel($factname, $parent);
                }
                echo '</th>';
                echo '<td class="', $styleadd, '">';
                if ($source) {
                    echo '<a href="', e($source->url()), '">', $source->fullName(), '</a>';
                    // PUBL
                    $publ = $source->facts(['PUBL'])->first();
                    if ($publ) {
                        echo GedcomTag::getLabelValue('PUBL', $publ->value());
                    }
                    // 2 RESN tags. Note, there can be more than one, such as "privacy" and "locked"
                    if (preg_match_all("/\n2 RESN (.+)/", $factrec, $rmatches)) {
                        foreach ($rmatches[1] as $rmatch) {
                            echo '<br><span class="label">', GedcomTag::getLabel('RESN'), ':</span> <span class="field">';
                            switch ($rmatch) {
                                case 'none':
                                    // Note: "2 RESN none" is not valid gedcom, and the GUI will not let you add it.
                                    // However, webtrees privacy rules will interpret it as "show an otherwise private fact to public".
                                    echo '<i class="icon-resn-none"></i> ', I18N::translate('Show to visitors');
                                    break;
                                case 'privacy':
                                    echo '<i class="icon-resn-privacy"></i> ', I18N::translate('Show to members');
                                    break;
                                case 'confidential':
                                    echo '<i class="icon-resn-confidential"></i> ', I18N::translate('Show to managers');
                                    break;
                                case 'locked':
                                    echo '<i class="icon-resn-locked"></i> ', I18N::translate('Only managers can edit');
                                    break;
                                default:
                                    echo $rmatch;
                                    break;
                            }
                            echo '</span>';
                        }
                    }
                    $cs = preg_match("/$nlevel EVEN (.*)/", $srec, $cmatch);
                    if ($cs > 0) {
                        echo '<br><span class="label">', GedcomTag::getLabel('EVEN'), ' </span><span class="field">', $cmatch[1], '</span>';
                        $cs = preg_match('/' . ($nlevel + 1) . ' ROLE (.*)/', $srec, $cmatch);
                        if ($cs > 0) {
                            echo '<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="label">', GedcomTag::getLabel('ROLE'), ' </span><span class="field">', $cmatch[1], '</span>';
                        }
                    }
                    echo self::printSourceStructure($tree, self::getSourceStructure($srec));
                    echo '<div class="indent">';
                    self::printMediaLinks($tree, $srec, $nlevel);
                    if ($nlevel === 2) {
                        self::printMediaLinks($tree, $source->gedcom(), 1);
                    }
                    echo FunctionsPrint::printFactNotes($tree, $srec, $nlevel);
                    if ($nlevel === 2) {
                        echo FunctionsPrint::printFactNotes($tree, $source->gedcom(), 1);
                    }
                    echo '</div>';
                } else {
                    echo $sid;
                }
                echo '</td></tr>';
            }
        }
    }
667655
public function update_one_data_set($tab_name, array $data, $id, $id_name)
    {

        $where = "$id_name = '$id' ";

        return $this->cuUpdate($tab_name, $data, $where);
    }
523004
@Override
    public void update(ChannelData cc) {
        this.chfwConfig = cc;
        this.myConfig = new HttpDispatcherConfig(cc.getPropertyBag());
    }
416997
def meta_fact_update(method, ts_begin, ts_end)
      connection[meta_collection].find_one_and_update(
        {},
        {
          '$set' => {
            last_fact_update: {
              ts_begin: ts_begin.iso8601,
              ts_end:   ts_end.iso8601,
              method:   method
            },
            method => {
              ts_begin: ts_begin.iso8601,
              ts_end:   ts_end.iso8601
            }
          }
        },
        { upsert: true }
      )
    end
1042796
public static function createEditForm(Fact $fact): void
    {
        $record = $fact->record();
        $tree   = $record->tree();

        self::$tags = [];

        $level0type = $record::RECORD_TYPE;
        $level1type = $fact->getTag();

        // List of tags we would expect at the next level
        // NB insertMissingSubtags() already takes care of the simple cases
        // where a level 1 tag is missing a level 2 tag. Here we only need to
        // handle the more complicated cases.
        $expected_subtags = [
            'SOUR' => [
                'PAGE',
                'DATA',
            ],
            'PLAC' => ['MAP'],
            'MAP'  => [
                'LATI',
                'LONG',
            ],
        ];
        
        if ($record::RECORD_TYPE !== 'SOUR') {
            //source citations within other records, i.e. n SOUR / +1 DATA / +2 TEXT
            $expected_subtags['DATA'][] = 'TEXT';
        } //else: source records themselves, i.e. 0 SOUR / 1 DATA don't get a 2 TEXT!

        if ($record::RECORD_TYPE === 'SOUR') {
            //source records themselves, i.e. 0 SOUR / 1 DATA / 2 EVEN get a 3 DATE and a 3 PLAC
            $expected_subtags['EVEN'][] = 'DATE';
            $expected_subtags['EVEN'][] = 'PLAC';
        }
        
        if ($record->tree()->getPreference('FULL_SOURCES')) {
            $expected_subtags['SOUR'][] = 'QUAY';
            
            if ($record::RECORD_TYPE !== 'SOUR') {
                //source citations within other records, i.e. n SOUR / +1 DATA / +2 DATE
                $expected_subtags['DATA'][] = 'DATE';
            } //else: source records themselves, i.e. 0 SOUR / 1 DATA don't get a 2 DATE!
        }

        if (GedcomCodeTemp::isTagLDS($level1type)) {
            $expected_subtags['STAT'] = ['DATE'];
        }

        if (in_array($level1type, Config::dateAndTime(), true)) {
            // TIME is NOT a valid 5.5.1 tag
            $expected_subtags['DATE'] = ['TIME'];
        }

        if (preg_match_all('/(' . Gedcom::REGEX_TAG . ')/', $record->tree()->getPreference('ADVANCED_PLAC_FACTS'), $match)) {
            $expected_subtags['PLAC'] = array_merge($match[1], $expected_subtags['PLAC']);
        }

        $stack       = [];
        $gedlines    = explode("\n", $fact->gedcom());
        $count       = count($gedlines);
        $i           = 0;
        $inSource    = false;
        $levelSource = 0;
        $add_date    = true;

        // Loop on existing tags :
        while ($i < $count) {
            $fields = explode(' ', $gedlines[$i], 3);
            $level  = (int) $fields[0];
            $type   = $fields[1] ?? '';
            $text   = $fields[2] ?? '';

            // Keep track of our hierarchy, e.g. 1=>BIRT, 2=>PLAC, 3=>FONE
            $stack[$level] = $type;
            // Merge them together, e.g. BIRT:PLAC:FONE
            $label = implode(':', array_slice($stack, 0, $level));

            // Merge text from continuation lines
            while ($i + 1 < $count && preg_match('/^' . ($level + 1) . ' CONT ?(.*)/', $gedlines[$i + 1], $cmatch) > 0) {
                $text .= "\n" . $cmatch[1];
                $i++;
            }

            if ($type === 'SOUR') {
                $inSource    = true;
                $levelSource = $level;
            } elseif ($levelSource >= $level) {
                $inSource = false;
            }

            self::$tags[] = $type;
            $subrecord    = $level . ' ' . $type . ' ' . $text;

            // Dates need different labels, depending on whether they are inside sources.
            if ($inSource && $type === 'DATE') {
                echo self::addSimpleTag($tree, $subrecord, '', GedcomTag::getLabel($label, $record));
            } elseif (!$inSource && $type === 'DATE') {
                echo self::addSimpleTag($tree, $subrecord, $level1type, GedcomTag::getLabel($label, $record));
                if ($level === 2) {
                    // We already have a date - no need to add one.
                    $add_date = false;
                }
            } elseif ($type === 'STAT') {
                echo self::addSimpleTag($tree, $subrecord, $level1type, GedcomTag::getLabel($label, $record));
            } else {
                echo self::addSimpleTag($tree, $subrecord, $level0type, GedcomTag::getLabel($label, $record));
            }

            // Get a list of tags present at the next level
            $subtags = [];
            for ($ii = $i + 1; isset($gedlines[$ii]) && preg_match('/^(\d+) (\S+)/', $gedlines[$ii], $mm) && $mm[1] > $level; ++$ii) {
                if ($mm[1] == $level + 1) {
                    $subtags[] = $mm[2];
                }
            }

            // Insert missing tags
            if (!empty($expected_subtags[$type])) {
                foreach ($expected_subtags[$type] as $subtag) {
                    if (!in_array($subtag, $subtags, true)) {
                        echo self::addSimpleTag($tree, ($level + 1) . ' ' . $subtag, '', GedcomTag::getLabel($label . ':' . $subtag));
                        if (!empty($expected_subtags[$subtag])) {
                            foreach ($expected_subtags[$subtag] as $subsubtag) {
                                echo self::addSimpleTag($tree, ($level + 2) . ' ' . $subsubtag, '', GedcomTag::getLabel($label . ':' . $subtag . ':' . $subsubtag));
                            }
                        }
                    }
                }
            }

            $i++;
        }

        if ($level1type !== '_PRIM') {
            //0 SOUR / 1 DATA doesn't get a 2 DATE!
            //0 SOUR / 1 DATA doesn't get a 2 EVEN here either, we rather handle this via cards/add-sour-data-even
            if ($record::RECORD_TYPE !== 'SOUR') {
                self::insertMissingSubtags($tree, $level1type, $add_date);
            }
        }
    }
733878
@Override
	public Response update(String CorpNum, String MgtKey, Cashbill cashbill,
			String UserID) throws PopbillException {
		if (MgtKey == null || MgtKey.isEmpty())
			throw new PopbillException(-99999999, "관리번호가 입력되지 않았습니다.");

		String PostData = toJsonString(cashbill);

		return httppost("/Cashbill/"+MgtKey, CorpNum,
				PostData, UserID, "PATCH", Response.class);
	}
1013555
def remove_fact(self, fact_id):
        """"""
        self.start_transaction()
        fact = self.__get_fact(fact_id)
        if fact:
            self.__remove_fact(fact_id)
            self.facts_changed()
        self.end_transaction()
127765
private void updateColumn(EntityType entityType, Attribute attr, Attribute updatedAttr) {
    // nullable changes
    if (!Objects.equals(attr.isNillable(), updatedAttr.isNillable())) {
      updateNillable(entityType, attr, updatedAttr);
    }

    // unique changes
    if (!Objects.equals(attr.isUnique(), updatedAttr.isUnique())) {
      updateUnique(entityType, attr, updatedAttr);
    }

    // readonly changes
    if (!Objects.equals(attr.isReadOnly(), updatedAttr.isReadOnly())) {
      updateReadonly(entityType, attr, updatedAttr);
    }

    // data type changes
    if (!Objects.equals(attr.getDataType(), updatedAttr.getDataType())) {
      if (updatedAttr.isReadOnly()) {
        dropTableTriggers(entityType);
      }
      updateDataType(entityType, attr, updatedAttr);
      if (updatedAttr.isReadOnly()) {
        createTableTriggers(entityType);
      }
    }

    // ref entity changes
    if (attr.hasRefEntity()
        && updatedAttr.hasRefEntity()
        && !attr.getRefEntity().getId().equals(updatedAttr.getRefEntity().getId())) {
      updateRefEntity(entityType, attr, updatedAttr);
    }

    // enum option changes
    if (!Objects.equals(attr.getEnumOptions(), updatedAttr.getEnumOptions())) {
      updateEnumOptions(entityType, attr, updatedAttr);
    }
  }
740431
def new_fact(self):
        """"""
        fact = lib.EnvCreateFact(self._env, self._tpl)
        if fact == ffi.NULL:
            raise CLIPSError(self._env)

        return new_fact(self._env, fact)
1329592
public function updateRecord(string $gedcom, bool $update_chan): void
    {
        // MSDOS line endings will break things in horrible ways
        $gedcom = preg_replace('/[\r\n]+/', "\n", $gedcom);
        $gedcom = trim($gedcom);

        // Update the CHAN record
        if ($update_chan) {
            $gedcom = preg_replace('/\n1 CHAN(\n[2-9].*)*/', '', $gedcom);
            $gedcom .= "\n1 CHAN\n2 DATE " . date('d M Y') . "\n3 TIME " . date('H:i:s') . "\n2 _WT_USER " . Auth::user()->userName();
        }

        // Create a pending change
        DB::table('change')->insert([
            'gedcom_id'  => $this->tree->id(),
            'xref'       => $this->xref,
            'old_gedcom' => $this->gedcom(),
            'new_gedcom' => $gedcom,
            'user_id'    => Auth::id(),
        ]);

        // Clear the cache
        $this->pending = $gedcom;

        // Accept this pending change
        if (Auth::user()->getPreference('auto_accept')) {
            FunctionsImport::acceptAllChanges($this->xref, $this->tree);
            $this->gedcom  = $gedcom;
            $this->pending = null;
        }

        $this->parseFacts();

        Log::addEditLog('Update: ' . static::RECORD_TYPE . ' ' . $this->xref, $this->tree);
    }
740186
function UpdateVisit($UserID, $ClientHour = FALSE) {
      $UserID = (int) $UserID;
      if (!$UserID) {
         throw new Exception('A valid User ID is required.');
      }
      
      $User = Gdn::UserModel()->GetID($UserID, DATASET_TYPE_ARRAY);
      
      $Fields = array();
      
      if (Gdn_Format::ToTimestamp($User['DateLastActive']) < strtotime('5 minutes ago')) {
         // We only update the last active date once every 5 minutes to cut down on DB activity.
         $Fields['DateLastActive'] = Gdn_Format::ToDateTime();
      }
      
      // Update session level information if necessary.
      if ($UserID == Gdn::Session()->UserID) {
         $IP = Gdn::Request()->IpAddress();
         $Fields['LastIPAddress'] = $IP;
         
         if (Gdn::Session()->NewVisit()) {
            $Fields['CountVisits'] = GetValue('CountVisits', $User, 0) + 1;
         }
      }
      
      // Generate the AllIPs field.
      $AllIPs = GetValue('AllIPAddresses', $User, array());
      if (is_string($AllIPs)) {
         $AllIPs = explode(',', $AllIPs);
         SetValue('AllIPAddresses', $User, $AllIPs);
      }
      if (!is_array($AllIPs))
         $AllIPs = array();
      if ($IP = GetValue('InsertIPAddress', $User))
         $AllIPs[] = ForceIPv4($IP);
      if ($IP = GetValue('LastIPAddress', $User))
         $AllIPs[] = $IP;
      $AllIPs = array_unique($AllIPs);
      sort($AllIPs);
      $Fields['AllIPAddresses'] = $AllIPs;

      // Set the hour offset based on the client's clock.
      if (is_numeric($ClientHour) && $ClientHour >= 0 && $ClientHour < 24) {
         $HourOffset = $ClientHour - date('G', time());
         $Fields['HourOffset'] = $HourOffset;
      }
      
      // See if the fields have changed.
      $Set = array();
      foreach ($Fields as $Name => $Value) {
         if (GetValue($Name, $User) != $Value) {
            $Set[$Name] = $Value;
         }
      }
      
      if (!empty($Set)) {
         $this->EventArguments['Fields'] =& $Set;
         $this->FireEvent('UpdateVisit');
         
         $this->SetField($UserID, $Set);
      }
      
      if ($User['LastIPAddress'] != $Fields['LastIPAddress']) {
         $User = $this->GetID($UserID, DATASET_TYPE_ARRAY);
         if (!BanModel::CheckUser($User, NULL, TRUE, $Bans)) {
            $BanModel = new BanModel();
            $Ban = array_pop($Bans);
            $BanModel->SaveUser($User, TRUE, $Ban);
            $BanModel->SetCounts($Ban);
         }
      }
   }
937942
public void updateDatabaseArtifacts() throws Exception {
        List<ModifiableConfigElement> mofiableElementList = new ArrayList<ModifiableConfigElement>();
        findModifiableConfigElements(this, mofiableElementList);

        for (ModifiableConfigElement element : mofiableElementList) {
            element.modify(this);
        }
    }
44851
function update(form) {
      // refuse to work with invalid data
      if (!vm.clientModelDoc._id || form && !form.$valid) {
        return;
      }

      ClientModelDocService.update(vm.clientModelDoc)
        .then(updateClientModelDocSuccess)
        .catch(updateClientModelDocCatch);

      function updateClientModelDocSuccess(updatedClientModelDoc) {
        // update the display name after successful save
        vm.displayName = updatedClientModelDoc.name;
        Toast.show({text: 'ClientModelDoc ' + vm.displayName + ' updated'});
        if (form) {
          form.$setPristine();
        }
      }

      function updateClientModelDocCatch(err) {
        Toast.show({
          type: 'warn',
          text: 'Error while updating ClientModelDoc ' + vm.displayName,
          link: {state: $state.$current, params: $stateParams}
        });

        if (form && err) {
          form.setResponseErrors(err.data);
        }
      }
    }
5979
public void doAdd(@FormGroup("dataMediaInfo") Group dataMediaInfo,
                      @FormField(name = "formDataMediaError", group = "dataMediaInfo") CustomErrors err, Navigator nav)
                                                                                                                       throws Exception {

        DataMedia dataMedia = new DataMedia();
        dataMediaInfo.setProperties(dataMedia);
        DataMediaSource dataMediaSource = dataMediaSourceService.findById(dataMediaInfo.getField("sourceId").getLongValue());
        if (dataMediaSource.getType().isMysql() || dataMediaSource.getType().isOracle()) {
            dataMedia.setSource((DbMediaSource) dataMediaSource);
        } else if (dataMediaSource.getType().isNapoli() || dataMediaSource.getType().isMq()) {
            dataMedia.setSource((MqMediaSource) dataMediaSource);
        }

        try {
            dataMediaService.create(dataMedia);
        } catch (RepeatConfigureException rce) {
            err.setMessage("invalidDataMedia");
            return;
        }

        nav.redirectTo(WebConstant.DATA_MEDIA_LIST_LINK);
    }
102376
public int update(Connection conn, Entity record, Entity where) throws SQLException {
		checkConn(conn);
		if(CollectionUtil.isEmpty(record)){
			throw new SQLException("Empty entity provided!");
		}
		if(CollectionUtil.isEmpty(where)){
			//不允许做全表更新
			throw new SQLException("Empty where provided!");
		}
		
		//表名可以从被更新记录的Entity中获得，也可以从Where中获得
		String tableName = record.getTableName();
		if(StrUtil.isBlank(tableName)){
			tableName = where.getTableName();
			record.setTableName(tableName);
		}
		
		final Query query = new Query(SqlUtil.buildConditions(where), tableName);
		PreparedStatement ps = null;
		try {
			ps = dialect.psForUpdate(conn, record, query);
			return ps.executeUpdate();
		} catch (SQLException e) {
			throw e;
		} finally {
			DbUtil.close(ps);
		}
	}