我尝试在ORACLE DATABASE中编译以下过程但得到错误 -PL / SQL:ORA-00923:找不到FROM关键字 -
程序 -
CREATE OR REPLACE PROCEDURE PendingTrailCasePropCrimeRepNw(
lang IN NUMBER,
date_from IN DATE,
date_to IN DATE,
cur OUT SYS_REFCURSOR)
IS
BEGIN
OPEN cur FOR SELECT
CASE
WHEN LANG=99 THEN
'MURDER FOR GAIN'
ELSE
'लाठके लिठहतà¥ÂÂया'
END
AS
'MURDER FOR GAIN',
---- ERROR STARTS HERE---
(SELECT COUNT(*)
FROM t_crime_major_minor_heads cdmh
INNER JOIN t_fir_registration fr
ON fr.FIR_REG_NUM=cdmh.FIR_REG_NUM
AND fr.LANG_CD =cdmh.LANG_CD
INNER JOIN t_final_report fnr
ON fnr.FIR_REG_NUM =cdmh.FIR_REG_NUM
AND fnr.LANG_CD =cdmh.LANG_CD
WHERE cdmh.MINOR_HEAD_CD =324
AND cdmh.MAJOR_HEAD_CD =36
AND fnr.FIR_REG_NUM NOT IN
(SELECT FIR_REG_NUM FROM t_court_disposal
)
AND fr.REG_DT BETWEEN TO_DATE(@startdate) AND TO_DATE(@enddate)
AND cdmh.LANG_CD=@LangCd
AND fr.PS_CD =@PS_CD
)
AS
PENDING_BEGINNING_YEAR,
(SELECT COUNT(*)
FROM t_crime_major_minor_heads cdmh
INNER JOIN t_fir_registration fr
ON fr.FIR_REG_NUM=cdmh.FIR_REG_NUM
AND fr.LANG_CD =cdmh.LANG_CD
INNER JOIN t_final_report fnr
ON fnr.FIR_REG_NUM =cdmh.FIR_REG_NUM
AND fnr.LANG_CD =cdmh.LANG_CD
WHERE cdmh.MINOR_HEAD_CD=324
AND cdmh.MAJOR_HEAD_CD =36
AND fr.REG_DT BETWEEN TO_DATE(@startdate) AND TO_DATE(@enddate)
AND cdmh.LANG_CD=@LangCd
AND fr.PS_CD =@PS_CD
)
AS
CASES_SEND_FOR_TRIAL,
(SELECT COUNT(*)
FROM t_crime_major_minor_heads cdmh
INNER JOIN t_fir_registration fr
ON fr.FIR_REG_NUM=cdmh.FIR_REG_NUM
AND fr.LANG_CD =cdmh.LANG_CD
INNER JOIN t_court_disposal cd
ON cd.FIR_REG_NUM =cdmh.FIR_REG_NUM
AND cd.LANG_CD =cdmh.LANG_CD
WHERE cdmh.MINOR_HEAD_CD=324
AND cdmh.MAJOR_HEAD_CD =36
AND fr.REG_DT BETWEEN TO_DATE(@startdate) AND TO_DATE(@enddate)
AND cdmh.LANG_CD=@LangCd
AND fr.PS_CD =@PS_CD
)
AS
CASES_DISPOSED,
(SELECT COUNT(*)
FROM t_crime_major_minor_heads cdmh
INNER JOIN t_fir_registration fr
ON fr.FIR_REG_NUM = cdmh.FIR_REG_NUM
AND fr.LANG_CD =cdmh.LANG_CD
WHERE MINOR_HEAD_CD =324
AND MAJOR_HEAD_CD =36
AND fr.FIR_REG_NUM NOT IN
(SELECT FIR_REG_NUM FROM t_final_report
)
AND fr.REG_DT > DATE_ADD(@startdate,INTERVAL '10' YEAR)
AND cdmh.LANG_CD=@LangCd
AND fr.PS_CD =@PS_CD
)
AS
MORE_THAN_10_YEARS,
(SELECT COUNT(*)
FROM t_crime_major_minor_heads cdmh
INNER JOIN t_fir_registration fr
ON fr.FIR_REG_NUM = cdmh.FIR_REG_NUM
AND fr.LANG_CD =cdmh.LANG_CD
WHERE cdmh.MINOR_HEAD_CD=324
AND cdmh.MAJOR_HEAD_CD =36
AND fr.FIR_REG_NUM NOT IN
(SELECT FIR_REG_NUM FROM t_final_report
)
AND fr.REG_DT BETWEEN DATE_ADD(@startdate,INTERVAL '5' YEAR) AND DATE_ADD(@enddate,INTERVAL '10' YEAR)
AND cdmh.LANG_CD=@LangCd
AND fr.PS_CD =@PS_CD
)
AS
MORE_THAN_5_LESS_THAN_10_YEARS,
(SELECT COUNT(*)
FROM t_crime_major_minor_heads cdmh
INNER JOIN t_fir_registration fr
ON fr.FIR_REG_NUM = cdmh.FIR_REG_NUM
AND fr.LANG_CD =cdmh.LANG_CD
WHERE cdmh.MINOR_HEAD_CD=324
AND cdmh.MAJOR_HEAD_CD =36
AND fr.FIR_REG_NUM NOT IN
(SELECT FIR_REG_NUM FROM t_final_report
)
AND fr.REG_DT BETWEEN DATE_ADD(@startdate,INTERVAL '4' YEAR) AND DATE_ADD(@enddate,INTERVAL '5' YEAR)
AND cdmh.LANG_CD=@LangCd
AND fr.PS_CD =@PS_CD
)
AS
MORE_THAN_4_LESS_THAN_5_YEARS,
(SELECT COUNT(*)
FROM t_crime_major_minor_heads cdmh
INNER JOIN t_fir_registration fr
ON fr.FIR_REG_NUM = cdmh.FIR_REG_NUM
AND fr.LANG_CD =cdmh.LANG_CD
WHERE cdmh.MINOR_HEAD_CD=324
AND cdmh.MAJOR_HEAD_CD =36
AND fr.FIR_REG_NUM NOT IN
(SELECT FIR_REG_NUM FROM t_final_report
)
AND fr.REG_DT BETWEEN DATE_ADD(@startdate,INTERVAL '3' YEAR) AND DATE_ADD(@enddate,INTERVAL '4' YEAR)
AND cdmh.LANG_CD=@LangCd
AND fr.PS_CD =@PS_CD
)
AS
MORE_THAN_3_LESS_THAN_4_YEARS,
(SELECT COUNT(*)
FROM t_crime_major_minor_heads cdmh
INNER JOIN t_fir_registration fr
ON fr.FIR_REG_NUM = cdmh.FIR_REG_NUM
AND fr.LANG_CD =cdmh.LANG_CD
WHERE cdmh.MINOR_HEAD_CD=324
AND cdmh.MAJOR_HEAD_CD =36
AND fr.FIR_REG_NUM NOT IN
(SELECT FIR_REG_NUM FROM t_final_report
)
AND fr.REG_DT BETWEEN DATE_ADD(@startdate,INTERVAL '2' YEAR) AND DATE_ADD(@enddate,INTERVAL '3' YEAR)
AND cdmh.LANG_CD=@LangCd
AND fr.PS_CD =@PS_CD
)
AS
MORE_THAN_2_LESS_THAN_3_YEARS,
(SELECT COUNT(*)
FROM t_crime_major_minor_heads cdmh
INNER JOIN t_fir_registration fr
ON fr.FIR_REG_NUM = cdmh.FIR_REG_NUM
AND fr.LANG_CD =cdmh.LANG_CD
WHERE cdmh.MINOR_HEAD_CD=324
AND cdmh.MAJOR_HEAD_CD =36
AND fr.FIR_REG_NUM NOT IN
(SELECT FIR_REG_NUM FROM t_final_report
)
AND fr.REG_DT BETWEEN DATE_ADD(@startdate,INTERVAL '1' YEAR) AND DATE_ADD(@enddate,INTERVAL '2' YEAR)
AND cdmh.LANG_CD=@LangCd
AND fr.PS_CD =@PS_CD
)
AS
MORE_THAN_1_LESS_THAN_2_YEARS,
(SELECT COUNT(*)
FROM t_crime_major_minor_heads cdmh
INNER JOIN t_fir_registration fr
ON fr.FIR_REG_NUM = cdmh.FIR_REG_NUM
AND fr.LANG_CD =cdmh.LANG_CD
WHERE cdmh.MINOR_HEAD_CD=324
AND cdmh.MAJOR_HEAD_CD =36
AND fr.FIR_REG_NUM NOT IN
(SELECT FIR_REG_NUM FROM t_final_report
)
AND fr.REG_DT BETWEEN DATE_ADD(@startdate,INTERVAL '6' MONTH) AND DATE_ADD(@enddate,INTERVAL '1' YEAR)
AND cdmh.LANG_CD=@LangCd
AND fr.PS_CD =@PS_CD
)
AS
MORE_THAN_6_MONTHS_LESS_THAN_1_YEAR,
(SELECT COUNT(*)
FROM t_crime_major_minor_heads cdmh
INNER JOIN t_fir_registration fr
ON fr.FIR_REG_NUM = cdmh.FIR_REG_NUM
AND fr.LANG_CD =cdmh.LANG_CD
WHERE cdmh.MINOR_HEAD_CD=324
AND cdmh.MAJOR_HEAD_CD =36
AND fr.FIR_REG_NUM NOT IN
(SELECT FIR_REG_NUM FROM t_final_report
)
AND fr.REG_DT < DATE_ADD(@startdate,INTERVAL '6' MONTH)
AND cdmh.LANG_CD=@LangCd
AND fr.PS_CD =@PS_CD
)
AS
LESS_THAN_6_MONTHS FROM dual;
END;
我是甲骨文的新手我不知道上述程序有什么问题,如何解决这个问题。 请帮我编译一下。提前致谢
错误 - PL / SQL:忽略SQL语句 ORA-00923:未找到FROM关键字
答案 0 :(得分:0)
这个评论太长了所以我会把它作为答案发布。
我建议使用select into变量而不是从dual构建这样的游标。所以
CREATE OR REPLACE PROCEDURE PendingTrailCasePropCrimeRepNw(
lang IN NUMBER,
date_from IN DATE,
date_to IN DATE,
cur OUT SYS_REFCURSOR)
IS
PENDING_BEGINNING_YEAR number;
MURDER_FOR_GAIN varchar2(4000);
BEGIN
if LANG=99 THEN
MURDER_FOR_GAIN := 'MURDER FOR GAIN';
ELSE
MURDER_FOR_GAIN := 'लाठके लिठहतà¥ÂÂया'
END IF;
SELECT COUNT(*) into PENDING_BEGINNING_YEAR
FROM t_crime_major_minor_heads cdmh
INNER JOIN t_fir_registration fr
ON fr.FIR_REG_NUM=cdmh.FIR_REG_NUM
AND fr.LANG_CD =cdmh.LANG_CD
INNER JOIN t_final_report fnr
ON fnr.FIR_REG_NUM =cdmh.FIR_REG_NUM
AND fnr.LANG_CD =cdmh.LANG_CD
WHERE cdmh.MINOR_HEAD_CD =324
AND cdmh.MAJOR_HEAD_CD =36
AND fnr.FIR_REG_NUM NOT IN
(SELECT FIR_REG_NUM FROM t_court_disposal
)
AND fr.REG_DT BETWEEN TO_DATE(@startdate) AND TO_DATE(@enddate)
AND cdmh.LANG_CD=@LangCd
AND fr.PS_CD =@PS_CD
from dual;
...