我需要实现从 PostgreSQL 数据库到 Oracle 数据库的更改数据捕获 (CDC)。
由于 PostgreSQL 的 CDC 没有日志化知识模块,我正在尝试调整 JKM Oracle Simple,如https://forums.oracle.com/forums/thread.jspa?threadID=620355中所述。
但是,我在使用 Jython“创建触发器”命令时遇到了问题。
在 ODI 中,我已将“创建触发器”命令替换为以下内容:
drop trigger if exists public_t_payment on public.payment;
drop sequence if exists idSequence;
CREATE SEQUENCE idSequence;
CREATE OR REPLACE FUNCTION public_t_payment_trigger() RETURNS TRIGGER AS $$
declare
V_FLAG VARCHAR(1);
V_id integer NOT NULL DEFAULT nextval('idSequence');
begin
if inserting then
V_id := NEW.id;
V_FLAG := 'I';
end if;
if updating then
V_id := NEW.id;
V_FLAG := 'I';
end if;
if deleting then
V_id := OLD.id;
V_FLAG := 'D';
end if;
insert into public.j$payment
(
JRN_SUBSCRIBER,
JRN_CONSUMED,
JRN_FLAG,
JRN_DATE,
id
)
select JRN_SUBSCRIBER,
'0',
V_FLAG,
sysdate,
V_id
from public."SNP_SUBSCRIBERS"
where JRN_TNAME = 'public.payment';
/* The following line can be uncommented for symetric replication */
/* and upper(USER) <> upper(''postgres'') */
end; $$ LANGUAGE plpgsql;
create trigger public_t_payment
after insert or update or delete on public.payment
for each row
execute procedure public_t_payment_trigger();
上面的代码在 PostgreSQL 上复制和执行时效果很好,但是当我在源表上执行“启动日志”时,ODI 给了我以下错误:
ODI-1217: Session payment (712013) fails with return code 7000.
ODI-1226: Step payment fails after 1 attempt(s).
ODI-1231: An error occurred while performing a Journal operation on datastore payment.
Caused By: org.apache.bsf.BSFException: exception from Jython:
SyntaxError: ("no viable alternative at character '$'", ('<string>', 6, 19, 'returns trigger as $test\n'))
问题似乎与触发器的返回“as”名称($$)有关,但我不知道如何在 Jython 中解决这个问题。