我的过程中有如下代码。当我调用该过程时,缺少右括号错误。当我在过程之外测试它时,没有立即执行子句,它工作正常。 有人会帮我消除错误吗?
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 || '))';
我假设你对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;