我的程序中有如下代码。当我调用该过程时,缺少右括号错误。当我在程序之外测试它时,没有执行立即子句,它工作正常。 有人会帮我解决这个错误吗?
EXECUTE IMMEDIATE '
INSERT INTO prehledcen
(id_obchodu
,id_obchodu_poradi
,smer
,typceny
,vzdalenost
,hodnotaceny
,kid)
SELECT a.id_obchodu
,a.id_obchodu_poradi
,smer
,''PredchoziLast''
,predchozi_last_time - datum_obchodu
,predchozi_last
,kid
FROM middle_office.f_d_obchody_zmeny_test a
INNER JOIN (SELECT id_obchodu
,id_obchodu_poradi
,MAX(dwh_insert_process) dwh_insert_process
,MIN(insert_sysdate) insert_sysdate
FROM middle_office.f_d_obchody_zmeny_test b
GROUP BY id_obchodu
,id_obchodu_poradi) b
ON b.id_obchodu = a.id_obchodu
AND b.id_obchodu_poradi = a.id_obchodu_poradi
AND a.dwh_insert_process = b.dwh_insert_process
WHERE (datum_obchodu >= ' || v_datum_od || ' OR
(datum_obchodu < ' || v_datum_od || ' AND b.insert_sysdate >= ' || v_datum_od || '))';
答案 0 :(得分:1)
我认为你的v_datum_od
值不好。试试这个:
EXECUTE IMMEDIATE '
INSERT INTO prehledcen
...
WHERE (datum_obchodu >= :d1 OR (datum_obchodu < :d2 AND b.insert_sysdate >= :d3))'
USING v_datum_od, v_datum_od, v_datum_od;