コード例 #1
0
        /// <summary>
        /// Ćhecks if the table or view exists. If the table doesn't exists, an ETLBoxException is thrown.        ///
        /// </summary>
        /// <param name="connectionManager">The connection manager of the database you want to connect</param>
        /// <param name="objectName">The table or view name that you want to check for existence</param>
        /// <exception cref="ETLBoxException" />
        public static void ThrowExceptionIfNotExists(IConnectionManager connectionManager, string objectName)
        {
            bool tableExists = new IfTableOrViewExistsTask(objectName)
            {
                ConnectionManager = connectionManager,
                DisableLogging    = true
            }.Exists();

            if (!tableExists)
            {
                throw new ETLBoxException($"A table {objectName} does not exists in the database!");
            }
        }
コード例 #2
0
 public void Execute()
 {
     IsExisting = new IfTableOrViewExistsTask(ViewName)
     {
         ConnectionManager = this.ConnectionManager, DisableLogging = true
     }.Exists();
     if (
         (ConnectionType == ConnectionManagerType.SQLite || ConnectionType == ConnectionManagerType.Access) &&
         IsExisting
         )
     {
         new DropViewTask(ViewName)
         {
             ConnectionManager = this.ConnectionManager, DisableLogging = true
         }
     }
コード例 #3
0
ファイル: CreateTableTask.cs プロジェクト: Sunny-365/etlbox
        public void Execute()
        {
            CheckTableDefinition();
            bool tableExists = new IfTableOrViewExistsTask(TableName)
            {
                ConnectionManager = this.ConnectionManager, DisableLogging = true
            }.Exists();

            if (tableExists && ThrowErrorIfTableExists)
            {
                throw new ETLBoxException($"Table {TableName} already exists!");
            }
            if (!tableExists)
            {
                new SqlTask(this, Sql).ExecuteNonQuery();
            }
        }