Exemple #1
0
 public SelectSQL()
 {
     this.tables  = new SQLTable();
     this.fields  = new FieldsSQL();
     this.where   = new WhereSQL();
     this.orderBy = new OrderBySQL();
     this.groupBy = new GroupBySQL();
     this.limit   = new LimitSQL();
 }
Exemple #2
0
        public override string GetSQLString(ISQL.DBType type)
        {
            if (!StringUtil.IsNullOrEmpty(this.sql))
            {
                return(this.sql);
            }
            string field = fields.Size() == 0 ? "*" : fields.GetSQLString(type);
            string sql   = string.Empty;

            if (type == ISQL.DBType.mysql || limit == null || (limit.GetCount() == 0 && limit.GetStart() == 0))
            {
                sql = "select " + field + " from " + tables.GetSQLString(type) + where.GetSQLString(type) + groupBy.GetSQLString(type) + orderBy.GetSQLString(type) + limit.GetSQLString(type);
            }
            else
            {
                WhereSQL w1 = where.Clone();
                w1.AddCondition(new SQLCondition("rownum", (limit.GetStart() + limit.GetCount() + 1).ToString(), "<", true));
                WhereSQL w2 = where.Clone();
                w2.AddCondition(new SQLCondition("rownum", (limit.GetStart() + 1).ToString(), "<", true));
                sql = "SELECT * FROM ( SELECT A.*, ROWNUM RNNNNNN FROM (SELECT " + field + " FROM " + tables.GetSQLString(type) + where.GetSQLString(type) + groupBy.GetSQLString(type) + orderBy.GetSQLString(type) + ") A WHERE ROWNUM <= " + (limit.GetStart()
                                                                                                                                                                                                                                                 + limit.GetCount()) + " ) WHERE RNNNNNN >= " + (limit.GetStart() + 1);
            }
            return(SQLUtils.RemoveMultiBlank(sql.Trim()).Trim());
        }
Exemple #3
0
 public DeleteSQL()
 {
     this.tables = new SQLTable();
     this.where  = new WhereSQL();
 }
Exemple #4
0
 public virtual void SetWhere(WhereSQL where)
 {
     this.where = where;
 }
Exemple #5
0
 public UpdateSQL()
 {
     this.tables      = new SQLTable();
     this.fieldValues = new FieldValuesSQL();
     this.where       = new WhereSQL();
 }