Esempio n. 1
0
        StringBuilder CreateSqlText()
        {
            CommandParams pars = Pars;

            string[] valueKeys = pars.GetAttachedValueKeys();
            var      stBuilder = new StringBuilder();

            stBuilder.Append("update ");
            stBuilder.Append(TargetTableName);
            stBuilder.Append(" set ");

            int j = valueKeys.Length;

            for (int i = 0; i < j; ++i)
            {
                string k = valueKeys[i];
                //sub string
                if (k[0] != '?')
                {
                    throw new System.NotSupportedException();
                }
                stBuilder.Append(k.Substring(1)); //remove ?
                stBuilder.Append('=');
                stBuilder.Append(k);

                if (i < j - 1)
                {
                    stBuilder.Append(',');
                }
            }

            //this version update must specific where
            //if not user must confirm that no where

            if (_whereClause == null)
            {
                if (!ConfirmNoWhereClause)
                {
                    throw new System.NotSupportedException("no where clause, or not confirm no where clause");
                }
            }
            else
            {
                stBuilder.Append(" where ");
                stBuilder.Append(_whereClause);
            }


            if (Limit != null)
            {
                stBuilder.Append(" limit " + Limit);
            }
            return(stBuilder);
        }
Esempio n. 2
0
        StringBuilder CreateSqlText()
        {
            CommandParams pars = Pars;

            string[] valueKeys = pars.GetAttachedValueKeys();
            var      stBuilder = new StringBuilder();

            stBuilder.Append("insert into ");
            stBuilder.Append(TargetTableName);
            stBuilder.Append('(');

            int j = valueKeys.Length;

            for (int i = 0; i < j; ++i)
            {
                string k = valueKeys[i];
                //sub string
                if (k[0] != '?')
                {
                    throw new System.NotSupportedException();
                }
                stBuilder.Append(k.Substring(1)); //remove ?

                if (i < j - 1)
                {
                    stBuilder.Append(',');
                }
            }
            stBuilder.Append(")  values(");
            for (int i = 0; i < j; ++i)
            {
                stBuilder.Append(valueKeys[i]);
                if (i < j - 1)
                {
                    stBuilder.Append(',');
                }
            }
            stBuilder.Append(")");
            return(stBuilder);
        }
Esempio n. 3
0
        StringBuilder CreateSqlText(DataRecordTypePlan typePlan)
        {
            CommandParams pars = Pars;

            string[] valueKeys = pars.GetAttachedValueKeys();
            var      stBuilder = new StringBuilder();

            stBuilder.Append("select ");

            int j = typePlan.fields.Count;

            for (int i = 0; i < j; ++i)
            {
                DataFieldPlan fieldPlan = typePlan.fields[i];
                stBuilder.Append(fieldPlan.name);
                if (i < j - 1)
                {
                    stBuilder.Append(',');
                }
            }

            stBuilder.Append(" from ");
            stBuilder.Append(TargetTableName);

            if (_whereClause != null)
            {
                stBuilder.Append(" where ");
                stBuilder.Append(_whereClause);
            }

            if (Limit != null)
            {
                stBuilder.Append(" limit " + Limit);
            }
            return(stBuilder);
        }