无法执行此操作。我正在尝试通过数据库链接(oradb2)将一些数据合并到另一个数据库的表中。当我尝试这样做时,我收到了 ORA-02069:此操作错误的global_names参数必须设置为TRUE 。我尝试更改会话并将global_names参数设置为“ TRUE”,但这不能解决问题。有什么我想念的吗?
先谢谢了。下面是我的代码:
MERGE INTO sample_table@oradb2 X
USING
(SELECT TO_VALUE,
FROM_VALUE,
to_date(data_date_dt, 'MM-DD-YYYY') as DATA_DATE_DT,
UTC_HR_TS,
DATA_TYPE_TX,
VALUE_NB,
LOCAL_TIME_TS
FROM V_SAMPLE_VIEW
WHERE DATA_TYPE_TX = 'XML'
) A ON (
X.FROM = A.FROM
AND X.TO = A.TO
AND X.TIMESTAMP = A.UTC_HR_TS)
WHEN MATCHED THEN
UPDATE
SET X.VAL = A.value_nb,
X.LOCAL_TIMESTAMP = A.LOCAL_TIME_ts
WHEN NOT MATCHED THEN
INSERT
(
FROM,
TO,
DATE,
TIMESTAMP,
VAL,
LOCAL_TIMESTAMP )
VALUES
(A.FROM_VALUE
A.TO_VALUE,
A.data_date_dt,
A.utc_hr_ts,
A.value_nb,
A.LOCAL_TIME_ts);
COMMIT;
EXCEPTION WHEN OTHERS THEN
ROLLBACK;
RAISE;
答案 0 :(得分:1)
尝试一下并与我们分享输出
BEGIN
MERGE INTO sample_table@oradb2 X
USING
(SELECT TO_VALUE,
FROM_VALUE,
to_date(data_date_dt, 'MM-DD-YYYY') as DATA_DATE_DT,
UTC_HR_TS,
DATA_TYPE_TX,
VALUE_NB,
LOCAL_TIME_TS
FROM V_SAMPLE_VIEW
WHERE DATA_TYPE_TX = 'XML'
) A ON (
X.FROM = A.FROM
AND X.TO = A.TO
AND X.TIMESTAMP = A.UTC_HR_TS)
WHEN MATCHED THEN
UPDATE
SET X.VAL = A.value_nb,
X.LOCAL_TIMESTAMP = A.LOCAL_TIME_ts
WHEN NOT MATCHED THEN
INSERT
(
FROM,
TO,
DATE,
TIMESTAMP,
VAL,
LOCAL_TIMESTAMP )
VALUES
(A.FROM_VALUE
A.TO_VALUE,
A.data_date_dt,
A.utc_hr_ts,
A.value_nb,
A.LOCAL_TIME_ts);
COMMIT;
EXCEPTION
WHEN OTHERS THEN
ROLLBACK;
dbms_output.put_line(SQLERRM || DBMS_UTILITY.format_error_backtrace);
end;