我正在尝试使用以下查询在iReport上创建报告,该查询在SSRS报告中运行正常。我是JasperReports的新手。如何在报表查询中声明变量?这是我的SQL查询:
Declare @SDate as Date
Declare @EDate as Date
Declare @JNumber as Char(8)
set @SDate = case When @StartDate > '1/1/2000' Then @StartDate Else GETDATE() End
set @EDate = case When @EndDate > '1/1/2000' Then @EndDate Else GETDATE() End
set @JNumber = ISNULL(@JobNumber, '')
select Distinct
j.JobNumber, j.CustomerRep, j.JobStatus, j.StatusDate, a.Answer14 'Ship Time' ,j.LastShippedDate, Cast(m.ExpectedDate as Date) 'ShipDate',
m.CustomerCode, RTrim(m.CustLongName) , RTrim(m.[Description]) 'JobName', RTrim(m.PONumber) 'PONumber', m.ProductCode, m.QuantityOrdered, a1.answer8'Pages'
from JobExtra j (NOLOCK)
Join JobMaster m (nolock) on m.JobNumber = j.JobNumber
where (@JNumber != '' AND @JNumber = j.JobNumber)
And @SDate <= Cast(ISNULL(ce.sStartDate, m.StartDate) As Date)
And @EDate >= Cast(ISNULL(ce.sStartDate, m.StartDate) As Date)
order by Case When @Sort = 'Ship Date' Then m.ExpectedDate When @Sort = 'Start Date' Then m.StartDate Else j.JobNumber End
, j.JobNumber, ce.sEndDate, ce.sEndTime, ce.sStartDate
错误是:
Error:java.sql.SQLException:Must Declare the scalar variable @StartDate
答案 0 :(得分:0)
好像你错过了两个变量。请像@State和@Edate一样声明变量@StartDate和@EndDate
例: 声明@StartDate日期 声明EndDate日期
请尝试一次
谢谢, Dhana