Exemple #1
0
        protected override void BuildStartCreateTableStatement(SqlCreateTableStatement createTable)
        {
            if (createTable.StatementHeader == null && createTable.Table !.TableOptions.HasCreateIfNotExists())
            {
                var table = createTable.Table;

                var isTemporary = IsTemporary(table.TableName.Name, table.TableOptions);

                _skipBrackets = true;
                StringBuilder.Append("IF (OBJECT_ID(N'");
                BuildPhysicalTable(table, null);
                StringBuilder.AppendLine("') IS NULL)");
                _skipBrackets = false;

                if (!isTemporary)
                {
                    Indent++;
                    AppendIndent().AppendLine("EXECUTE('");
                }

                Indent++;
            }

            base.BuildStartCreateTableStatement(createTable);
        }
Exemple #2
0
        protected override void BuildEndCreateTableStatement(SqlCreateTableStatement createTable)
        {
            base.BuildEndCreateTableStatement(createTable);

            if (createTable.StatementHeader == null && createTable.Table !.TableOptions.HasCreateIfNotExists())
            {
                if (!IsTemporary(createTable.Table.TableName.Name, createTable.Table.TableOptions))
                {
                    Indent--;
                    AppendIndent().AppendLine("')");
                }

                Indent--;
            }
        }
Exemple #3
0
        protected override void BuildStartCreateTableStatement(SqlCreateTableStatement createTable)
        {
            if (createTable.StatementHeader == null && createTable.Table !.TableOptions.HasCreateIfNotExists())
            {
                AppendIndent().AppendLine(@"BEGIN");

                Indent++;

                AppendIndent().AppendLine(@"DECLARE CONTINUE HANDLER FOR SQLSTATE '42710' BEGIN END;");
                AppendIndent().AppendLine(@"EXECUTE IMMEDIATE '");

                Indent++;
            }

            base.BuildStartCreateTableStatement(createTable);
        }
Exemple #4
0
        protected override void BuildEndCreateTableStatement(SqlCreateTableStatement createTable)
        {
            base.BuildEndCreateTableStatement(createTable);

            if (createTable.StatementHeader == null && createTable.Table !.TableOptions.HasCreateIfNotExists())
            {
                Indent--;

                AppendIndent()
                .AppendLine("';");

                Indent--;

                StringBuilder
                .AppendLine("END");
            }
        }