在期望以下 pl sql 之一时遇到符号 FROM

encountered the symbol FROM when expecting one of the following pl sql

我正在尝试从 datefield 中提取年份,但是当我使用提取时(年份来自 日期字段)我收到此错误

Encountered the symbol FROM when expecting one of the following pl sql

cursor o1 is 

select substr(tarifa,1,2), count(*)
from pol p, uvod u, doppov d
where extract(year FROM datum_dop) = EXTRACT(YEAR FROM sysdate) 
and izdavanje >='1-jul-13'
and p.orgjed = u.sorgz (+)
and DATUM_PREKIDA is not null
and p.polica=d.polica and d.pov_dopl='P'
and d.status='F'
and cisti_ao(p.polica)!=0 
group by substr(tarifa,1,2);

我哪里弄错了?

啊,这个是Forms,应该是6i吧

它的引擎不知道 extract 函数。将该行更改为

where to_char(datum_dop, 'yyyy') = to_char(sysdate, 'yyyy')

不过,这会使 datum_dop 列(如果存在)上的索引不可用并强制 Oracle 将日期转换为字符串,因此您宁愿尝试使用

where datum_dop >= trunc(sysdate, 'yyyy')
  and datum_dop < add_months(trunc(sysdate, 'yyyy'), 12)

除此之外:

  • count(*) 应该有一个别名(如果你打算使用它的话),例如count(*) as broj_tarifa
  • 如果 izdavanjedate,不要将它与字符串 ('1-jul-13') 进行比较,而是将其与日期进行比较,例如izdavanje >= to_date('01.07.2013', 'dd.mm.yyyy')
  • 所有列使用table别名