Ejemplo n.º 1
0
 private void BuildAsqlCreateFooter(AsqlBuilder ab)
 {
     ab.WriteLine(")");
     ab.DecIndent();
     ab.SlashLine("tabspace = :oldtabloc");
     ab.DecIndent();
     ab.SlashLine("end if");
 }
Ejemplo n.º 2
0
 private void BuildAsqlCreateHeader(AsqlBuilder ab, string tableName)
 {
     ab.SlashLine("on error exit");
     ab.SlashLine("define oldtabloc ident(50)");
     ab.IndentWrite("if not exists ");
     ab.SlashLine(tableName);
     ab.IncIndent();
     ab.SlashLine("begin sqlserver");
     ab.IncIndent();
     ab.IndentWriteLine("select distinct s.groupname into :oldtabloc");
     ab.IncIndent();
     ab.IndentWriteLine("from sysobjects t, sysindexes i, sysfilegroups s, syscolumns c");
     ab.IndentWriteLine("where t.type = 'U'");
     ab.IndentWriteLine("and t.id = c.id");
     ab.IndentWriteLine("and t.id = i.id");
     ab.IndentWriteLine("and (i.indid=0 OR i.indid=1)");
     ab.IndentWriteLine("and i.groupid = s.groupid");
     ab.IndentWrite("and t.name = '");
     ab.Write(tableName);
     ab.WriteLine("'");
     ab.DecIndent();
     ab.SlashLine();
     ab.DecIndent();
     ab.SlashLine("end /* sqlserver */");
     ab.SlashLine("begin oracle");
     ab.IncIndent();
     ab.IndentWriteLine("select tablespace_name into :oldtabloc");
     ab.IncIndent();
     ab.IndentWriteLine("from user_tables");
     ab.IndentWrite("where LOWER(table_name) = '");
     ab.Write(tableName);
     ab.WriteLine("'");
     ab.DecIndent();
     ab.SlashLine();
     ab.DecIndent();
     ab.SlashLine("end /* oracle */");
     ab.IndentWrite("create table ");
     ab.Write(tableName);
     ab.WriteLine(" (");
     ab.IncIndent();
 }
Ejemplo n.º 3
0
 private void BuildAsqlCreateLines(AsqlBuilder ab, List<AsqlColumnInfo> columns)
 {
     bool anyRows = false;
     columns.Sort((left, right) => String.Compare(left.Name, right.Name, StringComparison.Ordinal));
     int maxNameLength = columns.Max(x => x.Name.Length);
     foreach (AsqlColumnInfo column in columns)
     {
         if (column.Name != "agrtid")
         {
             if (anyRows)
             {
                 ab.WriteLine(",");
             }
             else
             {
                 anyRows = true;
             }
             ab.IndentWrite(column.Name);
             ab.Write(new string(' ', maxNameLength - column.Name.Length + 1));
             ab.Write(column.DataType);
         }
     }
 }
Ejemplo n.º 4
0
 public string GetCreateTableStatementAsql(string tableName)
 {
     List<AsqlColumnInfo> columns = GetAsqlColumnInfo(tableName);
     if (0 == columns.Count)
     {
         return null;
     }
     AsqlBuilder ab = new AsqlBuilder();
     BuildAsqlCreateHeader(ab, tableName);
     BuildAsqlCreateLines(ab, columns);
     BuildAsqlCreateFooter(ab);
     return ab.ToString();
 }