Esempio n. 1
0
        /// <summary>
        /// Set the default stored procedures names
        /// </summary>
        private void SetDefaultNames()
        {
            (var tableName, var trackingName) = OracleBuilder.GetParsers(this.TableDescription);

            var schema = string.IsNullOrEmpty(tableName.SchemaName) ? "" : tableName.SchemaName + ".";

            this.AddName(DbCommandType.SelectChanges, string.Format(selectChangesProcName, schema, tableName.ObjectName));
            this.AddName(DbCommandType.SelectChangesWitFilters, string.Format(selectChangesProcNameWithFilters, schema, tableName.ObjectName, "{0}"));
            this.AddName(DbCommandType.SelectRow, string.Format(selectRowProcName, schema, tableName.ObjectName));
            this.AddName(DbCommandType.InsertRow, string.Format(insertProcName, schema, tableName.ObjectName));
            this.AddName(DbCommandType.UpdateRow, string.Format(updateProcName, schema, tableName.ObjectName));
            this.AddName(DbCommandType.DeleteRow, string.Format(deleteProcName, schema, tableName.ObjectName));
            this.AddName(DbCommandType.InsertMetadata, string.Format(insertMetadataProcName, schema, tableName.ObjectName));
            this.AddName(DbCommandType.UpdateMetadata, string.Format(updateMetadataProcName, schema, tableName.ObjectName));
            this.AddName(DbCommandType.DeleteMetadata, string.Format(deleteMetadataProcName, schema, tableName.ObjectName));
            this.AddName(DbCommandType.Reset, string.Format(resetMetadataProcName, schema, tableName.ObjectName));

            this.AddName(DbCommandType.InsertTrigger, string.Format(insertTriggerName, schema, tableName.ObjectName));
            this.AddName(DbCommandType.UpdateTrigger, string.Format(updateTriggerName, schema, tableName.ObjectName));
            this.AddName(DbCommandType.DeleteTrigger, string.Format(deleteTriggerName, schema, tableName.ObjectName));

            this.AddName(DbCommandType.BulkTableType, string.Format(bulkTableTypeName, schema, tableName.ObjectName));
            this.AddName(DbCommandType.BulkTemporyTable, string.Format(bulkTemporyTableName, schema, tableName.ObjectName));
            this.AddName(DbCommandType.BulkTable, string.Format(bulkTableName, schema, tableName.ObjectName));

            this.AddName(DbCommandType.BulkInsertRows, string.Format(bulkInsertProcName, schema, tableName.ObjectName));
            this.AddName(DbCommandType.BulkUpdateRows, string.Format(bulkUpdateProcName, schema, tableName.ObjectName));
            this.AddName(DbCommandType.BulkDeleteRows, string.Format(bulkDeleteProcName, schema, tableName.ObjectName));
        }
        public string ScriptAddFilterColumn(DmColumn filterColumn)
        {
            var quotedColumnName = new ObjectNameParser(filterColumn.ColumnName, "[", "]");

            string str = string.Concat("Add new filter column, ", quotedColumnName.UnquotedString, ", to Tracking Table ", trackingName.QuotedString);

            return(OracleBuilder.WrapScriptTextWithComments(this.AddFilterColumnCommandText(filterColumn), str));
        }
Esempio n. 3
0
        public string DropUpdateTriggerScriptText()
        {
            var triggerName = this.oracleObjectNames.GetCommandName(DbCommandType.UpdateTrigger);
            var trigger     = $"DELETE TRIGGER {triggerName};";
            var str         = $"Drop Update Trigger for table {tableName.QuotedString}";

            return(OracleBuilder.WrapScriptTextWithComments(trigger, str));
        }
        public OracleBuilderTrackingTable(DmTable tableDescription, DbConnection connection, DbTransaction transaction)
        {
            this.tableDescription = tableDescription;
            this.connection       = connection as OracleConnection;
            this.transaction      = transaction as OracleTransaction;

            (this.tableName, this.trackingName) = OracleBuilder.GetParsers(this.tableDescription);
            this.oracleDbMetadata = new OracleDbMetadata();
        }
Esempio n. 5
0
        public OracleBuilderTrigger(DmTable tableDescription, DbConnection connection, DbTransaction transaction)
        {
            this.tableDescription = tableDescription;
            this.connection       = connection as OracleConnection;
            this.transaction      = transaction as OracleTransaction;

            (this.tableName, this.trackingName) = OracleBuilder.GetParsers(this.tableDescription);
            this.oracleObjectNames = new OracleObjectNames(this.tableDescription);
        }
Esempio n. 6
0
        public string DropTableScriptText()
        {
            StringBuilder stringBuilder   = new StringBuilder();
            var           tableNameScript = $"Drop Table {tableName.QuotedString}";
            var           tableScript     = BuildTableCommand().CommandText;

            stringBuilder.Append(OracleBuilder.WrapScriptTextWithComments(tableScript, tableNameScript));
            stringBuilder.AppendLine();
            return(stringBuilder.ToString());
        }
Esempio n. 7
0
        public string CreatePrimaryKeyScriptText()
        {
            StringBuilder stringBuilder = new StringBuilder();
            var           pkName        = $"Create primary keys for table {tableName.QuotedString}";
            var           pkScript      = BuildPkCommand().CommandText;

            stringBuilder.Append(OracleBuilder.WrapScriptTextWithComments(pkScript, pkName));
            stringBuilder.AppendLine();
            return(stringBuilder.ToString());
        }
Esempio n. 8
0
        public string CreateUpdateTriggerScriptText()
        {
            var           updTriggerName = this.oracleObjectNames.GetCommandName(DbCommandType.UpdateTrigger);
            StringBuilder createTrigger  = new StringBuilder($"CREATE TRIGGER {updTriggerName} ON {tableName.QuotedString} FOR EACH ROW ");

            createTrigger.AppendLine();
            createTrigger.AppendLine(this.UpdateTriggerBodyText());

            string str = $"Update Trigger for table {tableName.QuotedString}";

            return(OracleBuilder.WrapScriptTextWithComments(createTrigger.ToString(), str));
        }
Esempio n. 9
0
        public string AlterInsertTriggerScriptText()
        {
            var           insTriggerName = this.oracleObjectNames.GetCommandName(DbCommandType.InsertTrigger);
            StringBuilder createTrigger  = new StringBuilder($"ALTER TRIGGER {insTriggerName} AFTER INSERT ON {tableName.QuotedString} FOR EACH ROW ");

            createTrigger.AppendLine();
            createTrigger.AppendLine(this.InsertTriggerBodyText());

            string str = $"ALTER Trigger Insert for table {tableName.QuotedString}";

            return(OracleBuilder.WrapScriptTextWithComments(createTrigger.ToString(), str));
        }
Esempio n. 10
0
        public string AlterDeleteTriggerScriptText()
        {
            (var tableName, var trackingName) = OracleBuilder.GetParsers(this.tableDescription);
            var           delTriggerName = this.oracleObjectNames.GetCommandName(DbCommandType.DeleteTrigger);
            StringBuilder createTrigger  = new StringBuilder($"CREATE OR REPLACE TRIGGER {delTriggerName} AFTER DELETE ON {tableName.QuotedString} FOR EACH ROW ");

            createTrigger.AppendLine();
            createTrigger.AppendLine(this.InsertTriggerBodyText());

            string str = $"ALTER Trigger Delete for table {tableName.QuotedString}";

            return(OracleBuilder.WrapScriptTextWithComments(createTrigger.ToString(), str));
        }
Esempio n. 11
0
        public string CreateSchemaScriptText()
        {
            if (String.IsNullOrEmpty(this.tableDescription.Schema))
            {
                return(null);
            }

            StringBuilder stringBuilder    = new StringBuilder();
            var           schemaNameScript = $"Create Schema {tableName.SchemaName}";
            var           schemaScript     = $"Create Schema {tableName.SchemaName}";

            stringBuilder.Append(OracleBuilder.WrapScriptTextWithComments(schemaScript, schemaNameScript));
            stringBuilder.AppendLine();
            return(stringBuilder.ToString());
        }
Esempio n. 12
0
        public string CreateForeignKeyConstraintsScriptText(DmRelation constraint)
        {
            StringBuilder stringBuilder = new StringBuilder();

            var constraintName =
                $"Create Constraint {constraint.RelationName} " +
                $"between parent {constraint.ParentTable.TableName} " +
                $"and child {constraint.ChildTable.TableName}";

            var constraintScript = BuildForeignKeyConstraintsCommand(constraint).CommandText;

            stringBuilder.Append(OracleBuilder.WrapScriptTextWithComments(constraintScript, constraintName));
            stringBuilder.AppendLine();

            return(stringBuilder.ToString());
        }
        public string CreatePopulateFromBaseTableScriptText()
        {
            string str = string.Concat("Populate tracking table ", trackingName.QuotedString, " for existing data in table ", tableName.QuotedString);

            return(OracleBuilder.WrapScriptTextWithComments(this.CreatePopulateFromBaseTableCommandText(), str));
        }
        public string DropTableScriptText()
        {
            string str = string.Concat("Droping Tracking Table ", trackingName.QuotedString);

            return(OracleBuilder.WrapScriptTextWithComments(this.CreateTableCommandText(), str));
        }
        public string CreatePkScriptText()
        {
            string str = string.Concat("Create Primary Key on Tracking Table ", trackingName.QuotedString);

            return(OracleBuilder.WrapScriptTextWithComments(this.CreatePkCommandText(), str));
        }