create or replace
PROCEDURE PROMOLOG1 AS
CURSOR rule IS SELECT * FROM business_rules; --this table had where conditions to use
TYPE r_cursor IS REF CURSOR;
ruleMatch r_cursor;
row_id VARCHAR2(20);
query_test VARCHAR2(400);
BEGIN
FOR a IN rule LOOP
IF a.rule_name != 'Rule1' THEN
OPEN rulematch FOR 'SELECT rowid FROM cold_promo_log_dup P WHERE EXISTS( SELECT 1 FROM cold_promo_log_dup C WHERE ' || a.condition || ' AND rowid < P.rowid)';
dbms_output.put_line('matching completed for ' || a.rule_name);
LOOP
FETCH ruleMatch INTO row_id;
EXIT WHEN rulematch%notfound;
query_test := 'INSERT INTO cold_promo_log_duplicate SELECT * FROM cold_promo_log_dup WHERE rowid = ''' || row_id ||'''' ;
dbms_output.put_line(query_test);
--EXECUTE IMMEDIATE 'INSERT INTO cold_promo_log_duplicate SELECT * FROM cold_promo_log_dup WHERE rowid = ''' || row_id || '''';
INSERT INTO cold_promo_log_duplicate SELECT * FROM cold_promo_log_dup WHERE rowid = row_id ;
EXECUTE IMMEDIATE 'DELETE FROM cold_promo_log_dup WHERE rowid = ' || row_id;
END LOOP;
END IF;
END LOOP;
END PROMOLOG1;
在oracle中执行上述过程会引发以下错误:
Connecting to the database dedupe_preprod.
ORA-00904: "AAALJBABVAANSZDAAA": invalid identifier
ORA-06512: at "DEDUPE.PROMOLOG1", line 23
ORA-06512: at line 2
matching completed for Rule2
INSERT INTO cold_promo_log_duplicate SELECT * FROM cold_promo_log_dup WHERE rowid = 'AAALJBABvAANsZDAAA'
Process exited.
Disconnecting from the database dedupe_preprod.
当我打印 rowid 时,它有几个小写字母(AAALJBABvAANsZDAAA),但错误显示所有字母都大写(AAALJBABVAANSZDAAA)。数据库中没有大写的rowid,因此出现错误无效标识符。
任何帮助表示赞赏。