Crystal Reports 2008命令文本带参数

时间:2011-12-23 03:16:23

标签: oracle crystal-reports crystal-reports-2008

我有一个从SQL Developer正确运行的查询,但在尝试将其用作Crystal Reports 2008中带参数的命令文本查询时发生了炸弹。

查询(硬编码日期;正确运行为Oracle Query和CR 2008命令文本)

SELECT *
FROM   (SELECT PERSON.DISPLAYNAME AS NAME
               , LABOR.LA20       AS LABORRECEMPLOYEENUM
               , LABOR.LABORCODE  AS PERSONLABORCODE
        FROM   LABOR
               LEFT OUTER JOIN PERSON
                 ON ( LABOR.LABORCODE = PERSON.PERSONID )
        WHERE  LABOR.LA20 IS NOT NULL
               AND LABOR.ACTIVE = 1
               AND PERSON.DISPLAYNAME IS NOT NULL
               AND LOWER(PERSON.DISPLAYNAME) NOT LIKE '%kimball%'
               AND LOWER(PERSON.DISPLAYNAME) NOT LIKE '%electrico%'
               AND LOWER(PERSON.DISPLAYNAME) NOT LIKE '%misc labor cost adj%'
               AND LOWER(PERSON.DISPLAYNAME) NOT LIKE '%brossoit'
               AND LOWER(PERSON.DISPLAYNAME) NOT LIKE '%brossiot')PERSONINFO
       LEFT OUTER JOIN (SELECT *
                        FROM   LABTRANS
                        WHERE  LABTRANS.STARTDATE BETWEEN to_date('03/01/2011', 'mm/dd/yyyy') AND to_date('04/01/2011', 'mm/dd/yyyy')) REDUCEDLABORRANGE
         ON ( PERSONINFO.PERSONLABORCODE = REDUCEDLABORRANGE.LABORCODE )
WHERE  REDUCEDLABORRANGE.LABORCODE IS NULL; 

我想做什么

替换硬编码值:

WHERE  LABTRANS.STARTDATE BETWEEN to_date('03/01/2011', 'mm/dd/yyyy') AND to_date('04/01/2011', 'mm/dd/yyyy')

在命令文本中使用Crystal Reports参数。

我尝试过(和错误)

WHERE  LABTRANS.STARTDATE BETWEEN to_date({?BeginDate}, 'mm/dd/yyyy') AND to_date({?EndDate}, 'mm/dd/yyyy')

产生错误:找到了数字所在的非数字字符[数据库供应商代码:1858]

WHERE  LABTRANS.STARTDATE BETWEEN to_date('{?BeginDate}', 'mm/dd/yyyy') AND to_date('{?EndDate}', 'mm/dd/yyyy')

产生错误:缺少右括号[数据库供应商代码907]

解决方案的潜在关键

  • 我无法弄清楚Crystal实际上是在粘贴参数值,或者它们是如何传递给查询的。

1 个答案:

答案 0 :(得分:3)

当然,在我发布后不久,我找到了答案。

我意识到,我不相信Crystal会提前将日期放在正确的格式中(通常,不相信Crystal Reports是正确的选择)。

以下工作:

WHERE  LABTRANS.STARTDATE BETWEEN {?BeginDate} AND {?EndDate}

无需另外格式化日期,因为它们已经采用从Crystal流入Oracle的正确格式。