private bool RemoveNativeTableSequence(ObjectName tableName)
{
// If the Sequence or SequenceInfo tables don't exist then
// We can't add or remove native tables
if (tableName.Equals(SequenceTableName) ||
tableName.Equals(SequenceInfoTableName) ||
!Transaction.ObjectExists(SequenceTableName) ||
!Transaction.ObjectExists(SequenceInfoTableName)) {
return false;
}
// The SEQUENCE and SEQUENCE_INFO table
var seq = Transaction.GetMutableTable(SequenceTableName);
var seqi = Transaction.GetMutableTable(SequenceInfoTableName);
var list = seqi.SelectRowsEqual(2, Field.VarChar(tableName.Name), 1, Field.VarChar(tableName.Parent.FullName));
// Remove the corresponding entry in the SEQUENCE table
foreach (var rowIndex in list) {
var sid = seqi.GetValue(rowIndex, 0);
var list2 = seq.SelectRowsEqual(0, sid);
foreach (int rowIndex2 in list2) {
// Remove entry from the sequence table.
seq.RemoveRow(rowIndex2);
}
// Remove entry from the sequence info table
seqi.RemoveRow(rowIndex);
}
return true;
}