예제 #1
0
        public void RenderSql(ISqlDumper dmp)
        {
            var full = Node.Designer.Frame.GetFullColumnName(Edit.Text);
            int val;

            if (full != null)
            {
                full.WriteExpression(dmp);
            }
            else if (Int32.TryParse(Edit.Text.Trim(), out val))
            {
                dmp.WriteRaw(Edit.Text.Trim());
            }
            else if (Edit.Text.StartsWith("@") && m_supportsVars)
            {
                string name = Edit.Text.Substring(1), defval = "";
                if (name.Contains(":"))
                {
                    int pos = name.IndexOf(':');
                    defval = name.Substring(pos + 1);
                    name   = name.Substring(0, pos);
                }
                dmp.WriteRaw(String.Format("'###{0}||{1}###'", name, defval));
            }
            else
            {
                dmp.Put("%v", Edit.Text);
            }
        }
예제 #2
0
        private void DumpSubFolder(ISqlDumper dmp, string subfolder)
        {
            string dir = GetPrivateSubFolder(subfolder);

            if (!Directory.Exists(dir))
            {
                return;
            }
            string[] files = Directory.GetFiles(dir);
            Array.Sort(files);
            foreach (string f in files)
            {
                if (!f.ToLower().EndsWith(".sql"))
                {
                    continue;
                }
                using (StreamReader sr = new StreamReader(f))
                {
                    foreach (string sql in QueryTools.GoSplit(sr))
                    {
                        dmp.WriteRaw(sql);
                        dmp.EndCommand();
                    }
                }
            }
        }
예제 #3
0
 private void RunScript(ISqlDumper dmp)
 {
     using (var fr = GetInputStream())
     {
         foreach (string sql in QueryTools.GoSplit(fr))
         {
             dmp.WriteRaw(sql);
             dmp.EndCommand();
         }
     }
 }
예제 #4
0
 public override void GenerateSql(ISqlDumper dmp)
 {
     if (Original != null)
     {
         dmp.WriteRaw(Original.GetOriginalToken());
     }
     else
     {
         throw new NotImplementedError("DAE-00117");
     }
 }
예제 #5
0
 public override void GenerateSql(ISqlDumper dmp, IDataSynAdapter sada, SynSourceInfo info, SynQueryType qtype, Action <ISqlDumper> putCondition)
 {
     GenerateSqlToFrom(dmp, sada, info, qtype);
     dmp.Put("(");
     dmp.WriteRaw(Sql);
     dmp.Put(") sub");
     if (putCondition != null)
     {
         putCondition(dmp);
     }
     GenerateSqlOrder(dmp, sada, info, qtype);
 }
예제 #6
0
        public void GenerateScript(TableDataScript script, TableDataSetProperties props, ISqlDumper dmp)
        {
            switch (script)
            {
            case TableDataScript.Delete:
                if (!m_deleteQuery.IsEmpty())
                {
                    dmp.WriteRaw(m_deleteQuery);
                    if (!props.FilterSqlCondition.IsEmpty())
                    {
                        dmp.WriteRaw(" WHERE ");
                        dmp.WriteRaw(props.FilterSqlCondition);
                    }
                    dmp.EndCommand();
                }
                break;

            case TableDataScript.Select:
                dmp.WriteRaw(GetQuery(props, QueryType.Select));
                dmp.EndCommand();
                break;
            }
        }
예제 #7
0
        public void GenSqlDef(ISqlDumper dmp)
        {
            int sources = 0;

            if (TableOrView != null)
            {
                sources++;
            }
            if (SubQuery != null)
            {
                sources++;
            }
            if (SubQueryString != null)
            {
                sources++;
            }
            if (sources != 1)
            {
                throw new Exception("DBSH-00095 DmlfSource should have exactly one source");
            }

            if (TableOrView != null)
            {
                dmp.Put("%l%f", LinkedInfo, TableOrView);
            }
            if (SubQuery != null)
            {
                dmp.Put("(");
                SubQuery.GenSql(dmp);
                dmp.Put(")");
            }
            if (SubQueryString != null)
            {
                dmp.Put("(");
                dmp.WriteRaw(SubQueryString);
                dmp.Put(")");
            }
            if (Alias != null)
            {
                dmp.Put(" %i", Alias);
            }
            if (WithNoLock)
            {
                dmp.Put(" ^with (^nolock)");
            }
        }
예제 #8
0
        protected void GenerateSqlToFrom(ISqlDumper dmp, IDataSynAdapter sada, SynSourceInfo info, SynQueryType qtype)
        {
            dmp.Put("^select %,i", (IEnumerable <string>)info.KeyCols);

            if (qtype == SynQueryType.SelectKeyMd5)
            {
                var  colexprs = new List <string>();
                bool was      = false;
                foreach (string col in info.CompareCols)
                {
                    if (was)
                    {
                        colexprs.Add("'(SEP#n3f9)'");
                    }
                    var type = info.Model.Columns[col].DataType;
                    colexprs.Add(sada.Coalesce(sada.GetHashableString(dmp.Dialect.QuoteIdentifier(col), type), "'(NULL#093foew)'"));
                    was = true;
                }
                if (colexprs.Count == 0)
                {
                    colexprs.Add("'(NONEswgg5)'");
                }
                dmp.Put(",");
                dmp.WriteRaw(sada.Md5(sada.Concat(colexprs)));
            }
            if (qtype == SynQueryType.SelectKeyNull)
            {
                dmp.Put(",^null");
            }
            if (qtype == SynQueryType.SelectAll)
            {
                if (info.DataCols.Length > 0)
                {
                    dmp.Put(",%,i", (IEnumerable <string>)info.DataCols);
                }
            }
            dmp.Put(" from ");
        }
예제 #9
0
 public override void GenSql(ISqlDumper dmp)
 {
     dmp.Put("&r"); // dump separator if needed
     dmp.WriteRaw(Value);
 }
예제 #10
0
 public override void GenSql(ISqlDumper dmp)
 {
     dmp.Put("&r"); // dump separator if needed
     dmp.WriteRaw(Value);
 }
예제 #11
0
 public void GenerateDrop(ISqlDumper dmp)
 {
     dmp.WriteRaw(StdScripts.dropassembly.Replace("#ASMNAME#", m_name));
     dmp.EndCommand();
 }
예제 #12
0
 public override void GenSql(ISqlDumper dmp, IDmlfHandler handler)
 {
     dmp.WriteRaw(Value);
 }
예제 #13
0
        private void GenerateSql(ISqlDumper dmp)
        {
            var obj = olvNewTable.SelectedObject as ForeignKeyStruct;

            if (obj == null)
            {
                return;
            }
            if (m_exTable == null)
            {
                return;
            }
            if (rbtInner.Checked)
            {
                dmp.Put("^inner ^join");
            }
            if (rbtLeft.Checked)
            {
                dmp.Put("^left ^join");
            }
            if (rbtRight.Checked)
            {
                dmp.Put("^right ^join");
            }
            dmp.Put(" %f ", obj.NewTable);
            if (!tbxAlias.Text.IsEmpty())
            {
                dmp.Put("%s ", tbxAlias.Text);
            }
            dmp.Put("^on ");
            for (int col = 0; col < obj.Fk.Columns.Count; col++)
            {
                if (col > 0)
                {
                    dmp.Put(" ^and ");
                }
                if (m_exTable.Alias != null)
                {
                    dmp.WriteRaw(m_exTable.Alias);
                }
                else
                {
                    dmp.Put("%f", m_exTable.FullName);
                }
                dmp.Put(".");
                if (obj.BackRef)
                {
                    dmp.Put("%i", obj.Fk.PrimaryKeyColumns[col].ColumnName);
                }
                else
                {
                    dmp.Put("%i", obj.Fk.Columns[col].ColumnName);
                }
                dmp.Put(" = ");
                if (!tbxAlias.Text.IsEmpty())
                {
                    dmp.Put("%s", tbxAlias.Text);
                }
                else
                {
                    dmp.Put("%f", obj.NewTable);
                }
                if (obj.BackRef)
                {
                    dmp.Put(".%i", obj.Fk.Columns[col].ColumnName);
                }
                else
                {
                    dmp.Put(".%i", obj.Fk.PrimaryKeyColumns[col].ColumnName);
                }
            }
        }