我已经在Crystal Reports 10中创建了4个自定义函数。这些函数从数据库记录中获取日期时间值,并确定该日期时间属于当前会计年度或上一会计年度之内。Crystal Reports 10:是否可以通过命令调用自定义函数
这些计算以前是作为SQL Server上的存储过程执行的,但我们正在转移到另一个票据应用程序(托管在供应商站点),并且当前没有DB来执行这些计算。
下面是这些功能中的一个例子:
// Function name: isCloseDateWithinCurrentFY
Function (DateTimeVar closeTime)
// This replaces dbo.fn_FiscalYear
// Determine if the incident close date falls inside the current Fiscal Year
DateTimeVar startCurrentFiscalYear;
NumberVar currentMonth;
StringVar returnVal;
currentMonth := Month(CurrentDate);
If currentMonth >= 2 Then
startCurrentFiscalYear := Date(Year(CurrentDate), 2, 1)
Else
startCurrentFiscalYear := Date(Year(CurrentDate)-1, 2, 1);
If (closeTime >= startCurrentFiscalYear) Then
"T"
Else
"F";
当这些计算是在SQL Server上,它们是从水晶报表SQL命令
SELECT
category,
subcategory,
close_time,
tyCount
FROM (
SELECT
category=ISNULL(UPPER(category),'*Unspecified'),
subcategory=ISNULL(UPPER(subcategory),'*Unspecified'),
tyCount=SUM(CASE WHEN dbo.fn_FiscalYear(close_time)='T' THEN 1 ELSE 0 END)
FROM
incident_tickets
GROUP BY
UPPER(category),
UPPER(subcategory)
) tickets
WHERE
tycmCount>0
ORDER BY
category,
subcategory
利用在我来说,我希望通过拨打我的自定义功能isCloseDateWithinCurrentFY
替换对dbo.fn_FiscalYear
的呼叫。
但是有可能从SQL命令调用一个自定义函数吗?
或者是否有其他方法来限制基于在Crystal Report端进行的计算返回的记录?
TIA
多数民众赞成我认为,非常感谢您的投入瑞安。它可能是在Select Expert中使用自定义函数的替代方法吗? – user100487
您可以使用晶典在选择专家,但是这不会是尽可能快地将其转化为SQL因为实际的查询将不会改变,处理仍然会发生在客户端。这个问题应该有所帮助:http://stackoverflow.com/questions/2678869/round-date-to-fiscal-year – Ryan