我正在编写一个触发器,它将通过使用 LISTAGG 函数从表中提取数据来将新插入的行插入另一个表。这是插入和选择语句。我收到 ORA-00937: not a single-group group function 错误。类别需要一个包含多个值的字符串,由 ; 分隔 . 有没有其他方法可以从 JOBS_JOBCLASS、JOBS_CLASSIFICATION 表中获取类别?
这是片段:
INSERT INTO jobs_tfour_data
(
jobid,
title,
reference,
salary,
location,
department,
grade,
opendate,
closedate,
description,
internal,
category
)
select :new.jobid,:new.TITLE,:new.REFERENCE,:new.SALARY,LOCATIONNAME,DEPTNAME,GRADENAME,:new.OPENDATE,:new.CLOSEDATE,:new.description,:new.internal, LISTAGG(CLASSNAME,'; ') WITHIN GROUP (order by cj.CLASSID) as category
from JOBS_LOCATION l , JOBS_DEPARTMENT d, JOBS_GRADE g,JOBS_JOBCLASS cj ,JOBS_CLASSIFICATION c
where
l.locationid = :new.locationid
and d.deptid = :new.departmentid
and g.gradeid = :new.gradeid
and cj.jobid = :new.jobid
and cj.classid = c.classid
;