• Модуль: main
  • Путь к файлу: ~/bitrix/modules/main/lib/db/oracleconnection.php
  • Класс: BitrixMainDBOracleConnection
  • Вызов: OracleConnection::renameTable
public function renameTable($currentName, $newName)
{
	$this->query('RENAME '.$this->getSqlHelper()->quote($currentName).' TO '.$this->getSqlHelper()->quote($newName));

	// handle auto increment: rename primary sequence for ID
	// properly we should check PRIMARY fields instead of ID: $aiName = $currentName.'_'.$fieldName, see createTable
	$aiName = $currentName;

	if ($this->queryScalar("SELECT 1 FROM user_sequences WHERE sequence_name=upper('".$this->getSqlHelper()->forSql('sq_'.$aiName)."')"))
	{
		// for fields excpet for ID here should be $newName.'_'.$fieldName, see createTable
		$newAiName = $newName;

		// rename sequence
		$this->query('RENAME '.$this->getSqlHelper()->quote('sq_'.$aiName).' TO '.$this->getSqlHelper()->quote('sq_'.$newAiName));

		// recreate trigger
		$this->query('DROP TRIGGER '.$this->getSqlHelper()->quote($aiName.'_insert'));

		$this->query('CREATE OR REPLACE TRIGGER '.$this->getSqlHelper()->quote($newAiName.'_insert').'
					BEFORE INSERT
					ON '.$this->getSqlHelper()->quote($newName).'
					FOR EACH ROW
						BEGIN
						IF :NEW.'.$this->getSqlHelper()->quote('ID').' IS NULL THEN
							SELECT '.$this->getSqlHelper()->quote('sq_'.$newAiName).'.NEXTVAL
								INTO :NEW.'.$this->getSqlHelper()->quote('ID').' FROM dual;
						END IF;
					END;'
		);
	}
}