如何在oracle商店程序中将AND子句附加到查询中?

时间:2015-08-06 19:55:00

标签: oracle stored-procedures

我有两个名为CUSTOMERPRODUCT的表。我试图将一部分附加到正在运行的查询中。我尝试了以下内容,

CREATE OR REPLACE PROCEDURE GET_CUSTOMERS(
availability      IN PRODUCT.AVAILABILITY%TYPE,
customer_title    IN CUSTOMER.CUSTOMER_TITLE%TYPE,
from_date         IN VARCHAR2,
to_date           IN VARCHAR2,
customer_category IN VARCHAR2,
customers          OUT SYS_REFCURSOR)
IS
BEGIN

OPEN customers FOR
SELECT
  CUSTOMER.CUSTOMER_CODE
FROM CUSTOMER CUSTOMER INNER JOIN PRODUCT PRODUCT ON CUSTOMER.CUSTOMER_CODE = PRODUCT.CUSTOMER_CODE
WHERE AVAILABILITY = GET_CUSTOMERS.availability AND
      (CUSTOMER.CREATED_DATE BETWEEN TO_DATE(GET_CUSTOMERS.from_date, 'DD-MM-YYYY hh24:mi:ss')
      AND TO_DATE(GET_CUSTOMERS.to_date, 'DD-MM-YYYY hh24:mi:ss'))
      AND GET_CUSTOMERS.CUSTOMER_category
      AND (PRODUCT.PRODUCT_SKU_ID = 'b36e3e27-61d6-4080-9383-d5397110698d')
      AND (LOWER(CUSTOMER.CUSTOMER_TITLE) LIKE LOWER('%' || GET_CUSTOMERS.CUSTOMER_title || '%'))
GROUP BY CUSTOMER.CUSTOMER_CODE;
END;
/

我试图追加的字符串部分是 GET_CUSTOMERS.CUSTOMER_category

我收到了以下错误。

PLS-00905: object SYSTEM.GET_CUSTOMERS is invalid
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored

我该如何解决这个问题?

0 个答案:

没有答案