我在使用合并编译触发器时遇到问题
I have problem compile trigger using merge
你能解释一下我的代码哪里出错了吗?
CREATE OR REPLACE TRIGGER mda_01.tr_01_t01003 AFTER
INSERT ON mda_01.t01004_bo_semafor_log
FOR EACH ROW
DECLARE
PRAGMA autonomous_transaction;
BEGIN
IF inserting THEN
MERGE INTO mda_01.t01003_bo_semafor a
USING (
SELECT
:new.semafor_name,
:new.semafor_ts,
:new.semafor_status,
:new.semafor_desc
FROM
dual
) b
ON ( b.semafor_name = a.semafor_name )
WHEN MATCHED THEN UPDATE
SET a.semafor_ts = b.semafor_ts,
a.semafor_status = b.semafor_status
WHEN NOT MATCHED THEN
INSERT (
semafor_name,
semafor_ts,
semafor_status,
semafor_desc )
VALUES
( b.semafor_name,
b.semafor_ts,
b.semafor_status,
b.semafor_desc );
END IF;
COMMIT;
END;
/
我收到一个错误:
LINE/COL错误
5/6 PL/SQL:SQL 语句被忽略
16/8 PL/SQL: ORA-00904: "B"."SEMAFOR_NAME": 无效标识符
错误:检查编译器日志
谢谢,保罗
我解决了这个问题。
我添加了别名,触发器编译没有错误:
SELECT
:new.semafor_name as semafor_name,
:new.semafor_ts as semafor_ts,
:new.semafor_status as semafor_status,
:new.semafor_desc as semafor_desc
FROM
dual
你能解释一下我的代码哪里出错了吗?
CREATE OR REPLACE TRIGGER mda_01.tr_01_t01003 AFTER
INSERT ON mda_01.t01004_bo_semafor_log
FOR EACH ROW
DECLARE
PRAGMA autonomous_transaction;
BEGIN
IF inserting THEN
MERGE INTO mda_01.t01003_bo_semafor a
USING (
SELECT
:new.semafor_name,
:new.semafor_ts,
:new.semafor_status,
:new.semafor_desc
FROM
dual
) b
ON ( b.semafor_name = a.semafor_name )
WHEN MATCHED THEN UPDATE
SET a.semafor_ts = b.semafor_ts,
a.semafor_status = b.semafor_status
WHEN NOT MATCHED THEN
INSERT (
semafor_name,
semafor_ts,
semafor_status,
semafor_desc )
VALUES
( b.semafor_name,
b.semafor_ts,
b.semafor_status,
b.semafor_desc );
END IF;
COMMIT;
END;
/
我收到一个错误:
LINE/COL错误
5/6 PL/SQL:SQL 语句被忽略
16/8 PL/SQL: ORA-00904: "B"."SEMAFOR_NAME": 无效标识符
错误:检查编译器日志
谢谢,保罗
我解决了这个问题。 我添加了别名,触发器编译没有错误:
SELECT
:new.semafor_name as semafor_name,
:new.semafor_ts as semafor_ts,
:new.semafor_status as semafor_status,
:new.semafor_desc as semafor_desc
FROM
dual