Crystal报告返回的值类似于寻找而不是相等的值

时间:2019-05-30 18:56:11

标签: where selection equals crystal-reports-2008

我正在创建一个Report => selectionFormulas => Record,然后我有了它:

DECLARE

  /* Cursor Pointer */
  cur_Query   SYS_REFCURSOR;

  /* Store Dynamic SQL */
  q           VARCHAR2(2000);

  /* Declare Record based on Dynamic SQL */
  --rec_cursor_query  ????table%ROWTYPE;  /* I realize I can't do this... but what can I do? */

BEGIN

  /* Fake Query Below saved into q */
  q   :=    q'~SELECT 1001 AS pkey, 'Jake' AS firstname, 'Johnson' AS lastname FROM dual~';

  /* Output Query just to show query was saved */
  dbms_output.put_line(q);

  OPEN cur_Query FOR
    q;

  LOOP

    FETCH cur_Query INTO rec_cursor_query; /* Again here... I can't do this due to it not being Defined */

    EXIT WHEN cur_Query%NOTFOUND;

  END LOOP;

  CLOSE cur_Query;


END
;

由于某种原因,它会同时返回“有效”和“无效”两个值。它对我以及我在网上找到的说明来说都是正确的。我该如何解决它只返回“活动”的?有什么问题吗?

1 个答案:

答案 0 :(得分:0)

我知道了。我需要在最后两件事周围加上一组括号:

({Facilities_ALL.Fac} IN ['S', 'H', 'E', 'J', 'SJ', 'F', 'N'])
AND
({Facilities_ALL.status}="Active")
AND
(
isNull({Facilities_ALL.Department}) 
OR
isNull({Facilities_ALL.Section})
)