我已经编写了这个程序,当我尝试运行它时,我收到错误“ORA-00933”。我已经添加了更新语句,之后发生了错误。在此之前它有效。
可能是什么问题?
DECLARE
---values---
v_sidcount sitetb.sid%type;
v_sid sitetb.sid%type;
v_cid sitetb.cid%type := 46;
v_sptid sitetb.sptid%type := 215;
BEGIN
---count---
SELECT count(sid) into v_sidcount FROM sitetb
WHERE NOT EXISTS (SELECT sid FROM kam_report_ttn
WHERE sid = sitetb.sid
) and cid = v_cid and sptid = v_sptid;
---find all data---
SELECT max(sid) into v_sid FROM sitetb
WHERE NOT EXISTS (SELECT sid FROM kam_report_ttn
WHERE sid = sitetb.sid
) and cid = v_cid and sptid = v_sptid;
---insert into table---
insert into KAM_REPORT_TTN (sid)
values (v_sid);
---update comments---
UPDATE KAM_REPORT_TTN SET comments = (SELECT addeddate || ', ' || responseperson || ': ' || candidatenote || ' ' FROM candidatetb_extra)
where sid = v_sid order by noteid desc;
UPDATE KAM_REPORT_TTN SET comments2 = (SELECT addeddate || ', ' || responseperson || ': ' || sitenote || ' ' FROM sitetb_extra)
where sid = v_sid order by noteid desc;
dbms_output.put_line
(v_sid || '/' ||v_sidcount);
END;
/
错误:
ORA-06550:第 29 行,第 19 列:
PL/SQL: ORA-00933: SQL 命令未正确结束ORA-06550:第 27 行,第 1 列:
PL/SQL:忽略 SQL 语句ORA-06550:第 33 行,第 19 列:
PL/SQL: ORA-00933: SQL 命令未正确结束ORA-06550:第 31 行,第 1 列:
PL/SQL:忽略 SQL 语句
行错误:7 列:0
这看起来像您正在尝试通过更新语句应用订单:
order by noteid desc;
我猜你的意思是将其包含在选择子查询中,所以:
UPDATE KAM_REPORT_TTN SET comments = (SELECT addeddate || ', ' || responseperson || ': ' || candidatenote || ' ' FROM candidatetb_extra order by noteid desc)
where sid = v_si
我不确定你的 where 子句是否放在正确的位置。