我在SQL数据库中,写了一个存储过程,最后以select 语句结束,没有参数的。在FineReport8.0要如何调用这个存储过程,直接运行exec p_temp。预览出来是空值。
存储过程如下:
create proc . as
begin
If Object_Id( 'Tempdb.dbo.#temp') Is Not NULL
Begin
drop table #temp
End
select Ywy ,YEAR(QSDate) as year,MONTH(QSDate) as month,BProductTypeName,COUNT(*) as salecount,0.0000 as ty into #temp from (
select Ywy,QSDate,e.BProductTypeName from s_contract a ,p_Room b
left outer join p_Building dd on dd.BldGUID=b.BldGUID
left outer join cb_Product on cb_Product.ProductGUID = dd.ProductGUID
left outer join p_BuildProductType e on e.BProductTypeCode = cb_Product.BProductTypeCode
WHERE a.RoomGUID=b.RoomGUID and
a.projguid=( '537CECF8-9FE9-4FD1-90D2-47B8F51D2F25' ) and a.Status='激活') a
group by Ywy ,YEAR(QSDate),MONTH(QSDate),BProductTypeName
update #temp set ty=(case when BProductTypeName in('住宅','别墅','商铺') and salecount<4 then 0.002
when BProductTypeName in('住宅','别墅','商铺') and salecount=4 then 0.0025
when BProductTypeName in('住宅','别墅','商铺') and salecount=5 then 0.003
when BProductTypeName in('住宅','别墅','商铺') and salecount=6 then 0.0035
when BProductTypeName in('住宅','别墅','商铺') and salecount>6 then 0.004
when BProductTypeName in('车位') then 500 end )
If Object_Id( 'Tempdb.dbo.#temp1') Is Not NULL
Begin
drop table #temp1
End
--置业顾问提佣明细表
select RoomInfo, --房间信息
ProductType, ---业态
QSDate, --签约日期
HtTotal, --合同总价
yssq, --应收首期
ssk, --实收款
Ywy, --业务员
rh_jysDate, --交接钥匙日期
yjze, --佣金总额
(case when ssk-yssq>=0 then yjze*0.3 else 0.00 end)as qyyj, --签约佣金
(case when ssk-HtTotal>=0 then yjze*0.5 else 0.00 end)as fkyj, --银行放款佣金
(case when YEAR(GETDATE())-YEAR(QSDate)>0 and ssk-yssq>=0 then yjze*0.1 else 0.00 end)as ndyj, --年底佣金
(case when rh_jysDate IS null then 0.00 else yjze*0.1 end)as jfyj, --成功交房佣金
qtykk, --其他应扣款
yfyj into #temp1 from --已发佣金
(select a.ProjGUID,p.ProjName,a.RoomInfo,a.ProductType,a.Status,b.QSDate,b.HtTotal,b.Ywy,
(select c1.CompleteDate from s_SaleService b1,s_SaleServiceProc c1
where b1.SaleServiceGUID =c1.SaleServiceGUID and b1.ServiceItem = '入伙服务'
and c1.ServiceProc='已交接钥匙' and b1.ContractGUID = b.ContractGUID) as rh_jysDate,
ty,(case when ty<1 then HtTotal*ty else ty end) as yjze,
isnull(s.yfyj,0) as yfyj,isnull(s.qtykk,0) as qtykk,
d.yssq,e.ssk from ep_room a
left join p_Project p on p.ProjGUID=a.ProjGUID
left join s_contract b on b.RoomGUID=a.RoomGUID
left join s_Trade c on c.TradeGUID=b.TradeGUID and c.RoomGUID=a.RoomGUID
left join #temp t on t.year=year(b.QSDate) and t.month=month(b.QSDate) and t.Ywy=b.Ywy
left join salejcb s on s.RoomInfo=a.RoomInfo
left join (select tradeguid,
sum(case when ItemName in ('定金','首期') then amount else ''end ) as yssq
from s_fee group by TradeGUID ) d on c.TradeGUID=d.TradeGUID
left join (select saleguid,
sum(case when ItemName in ('定金','首期') then amount else ''end ) as sssq,
SUM(amount)as ssk from s_Getin
group by SaleGUID) e on c.TradeGUID=e.SaleGUID
where a.ProjGUID='537CECF8-9FE9-4FD1-90D2-47B8F51D2F25' and a.Status='签约') yj
select Ywy,COUNT(*)as number,SUM(qyyj+fkyj+ndyj+jfyj)as '应发佣金总额',
SUM(yfyj)as yfyj,SUM(qtykk)as qtykk,SUM(qyyj+fkyj+ndyj+jfyj-yfyj-qtykk)as syyj from #temp1
group by Ywy
order by ywy
end