4 Replies Latest reply on Jun 21, 2012 1:54 PM by Joel_C

    Simple function is producing an error.

    944520
      Following function is generating "Error at line 7: PLS-00456: item 'ARRAY_DEMAND_NO' is not a cursor" error.

      Can you help?

      Thank you

      CREATE OR REPLACE FUNCTION debt_balance(payment_date IN DATE)
      RETURN NUMBER IS
      total_outstanding_debt NUMBER(20,2) := 0;
      array_demand_no NUMBER(10);
      BEGIN
      SELECT DISTINCT DEMAND_NO INTO array_demand_no FROM DEMAND_TABLE WHERE PAYMENT_DT = payment_date;
      FOR each_demand_no IN array_demand_no
      LOOP
      SELECT SUM(BALANCE) AS "balance" FROM DEMAND_TABLE WHERE DEMAND_NO = each_demand_no AND PAYMENT_DT > payment_date;
      total_outstanding_debt := total_outstanding_debt + balance;
      END LOOP;
      RETURN total_outstanding_debt;
      END;