日期:2014-05-18  浏览次数:20805 次

NHabernate 查询插入语句 select into
public IList retrieveNewTrans(TranslineFilter filter)
  {
  string str = "EX686";
  string sHql = " select into NewTransline p0 from (select count(TraId),Oilcarrier,Tradate,Equipcode,Class,IssueToEamcode,OiltypeEamStore,OiltypeEamBin,sum(Oilqtyvolume),sum(Oilqty),EvttypeDesc,Oilingcheck,Oiledcheck,Eamsydn from Transline where Equipcode='" + str + "' group by Equipcode) ";
  sHql += " where 1=1 ";
  if (filter.TranType != null && filter.TranType.Trim() != string.Empty)
  {
  sHql += " and p0.Evttype = '" + filter.TranType + "'";
  }
  if (filter.Trandept != null && filter.Trandept.Trim() != string.Empty && filter.Trandept != "*")
  {
  sHql += " and p1.CarDept like '" + filter.Trandept + "%'";
  }
  if (filter.StartDate != null)
  {
  sHql += " and p0.Tradate >= to_date('" + filter.StartDate.ToString() + "','yyyy-MM-dd HH24:mi:ss') ";
  }
  if (filter.FinishDate != null)
  {
  sHql += " and p0.Tradate <= to_date('" + filter.FinishDate.ToString() + "','yyyy-MM-dd HH24:mi:ss') ";
  }
  if (filter.TranEmp != null && filter.TranEmp.Trim() != string.Empty)
  {
  sHql += " and p0.Empcode = '" + filter.TranEmp + "'";
  }
  if (filter.TranCarcode != null && filter.TranCarcode.Trim() != string.Empty)
  {
  sHql += " and p1.CarCode = '" + filter.TranCarcode + "'";
  }
  if (filter.TranOiltype != null && filter.TranOiltype.Trim() != string.Empty)
  {
  sHql += " and p0.Oiltype = '" + filter.TranOiltype + "'";
  }

  sHql += " and p0.Oilqty > 0)";
  return control.GetEntities(sHql);
  }


语句有错,求高手指点。

------解决方案--------------------
插入新表是这样写的

SELECT * INTO NewTransline FROM tableA