SQL语句被忽略了

时间:2014-07-24 09:11:21

标签: plsql

我在SQL中编写此代码并收到以下错误:

LINE/COL ERROR
-------- -----------------------------------------------------------------
7/2  PL/SQL: SQL Statement ignored

说明:

CREATE OR REPLACE FUNCTION GET_C_O(vretail_outlet_id int,
                                   vtran_year varchar)
  RETURN number
AS
  stock number;
BEGIN
  select vretail_outlet_id,
         SUM(GET_C_O_STOCKFN_TEST(61, a.BATCHID, 1,
                                  to_date('204-04-01','yyyy-mm-dd'),
                                  vretail_outlet_id, vtran_year, 1) * QP.PRODUCTRATE) AS OPENING
    From Promas
    inner join Product A
      on Promas.Pcode = A.Pcode and
         vretail_outlet_id = A.Retail_outlet_id and
         vtran_year = a.tran_year
    inner Join QryProductrate Qp
      on Qp.batchid = a.batchid and
         QP.Retail_outlet_id = a.REtail_outlet_id and
         Qp.Tran_year = a.tran_year
    where a.tran_year = '2014_2015' and
          1=1
    group by vretail_outlet_id)
    into stock
    from dual;

Return Stock;
END;

1 个答案:

答案 0 :(得分:1)

SELECT语句不正确。尝试:

select SUM(GET_C_O_STOCKFN_TEST(61, a.BATCHID, 1,
                                to_date('2014-04-01','yyyy-mm-dd'),
                                vretail_outlet_id, vtran_year, 1) * QP.PRODUCTRATE) AS OPENING
  into stock
  From Promas
  inner join Product A
    on Promas.Pcode = A.Pcode and
       vretail_outlet_id = A.Retail_outlet_id and
       vtran_year = a.tran_year
  inner Join QryProductrate Qp
    on Qp.batchid = a.batchid and
       QP.Retail_outlet_id = a.REtail_outlet_id and
       Qp.Tran_year = a.tran_year
  where a.tran_year = '2014_2015';

分享并享受。