Import data from PostgreSQL to Oracle
943135Jul 20 2012 — edited Jul 20 2012Good Afternoon,
I am doing a migration of data from a database PostgreSql for Oracle through a database link and using procedures to read the data and populate the Oracle tables. At the moment I found the following difficulty. What to bring data from one table PostgeSql that has a relationship with pg_largeobject. She returns the following error: ORA-22992 can not use lob locators selected from remote tables
My postgres and structure of the following:
eventresult (id bigint NOT NULL, version bigint NOT NULL, binary_data oid, value numeric (19,2) NOT NULL, event_id bigint NOT NULL, routine_id bigint NOT NULL)
pg_largeobject (oid NOT NULL loid, pageno integer NOT NULL, data bytea)
this relationship in binary_data (eventresult) with loid (pg_largeobject)
My oracle and the following structure:
+"EVENTRESULT" ("ID" NUMBER (19), "VERSION" NUMBER (19) NOT NULL, "BINARY_DATA" BLOB, "VALUE" NUMBER (19, 2) NOT NULL, "event_id" NUMBER (19) NOT NULL, "ROUTINE_ID" NUMBER (19) NOT NULL)+
I created the following procedure to perform the population:
create or replace
THE PROCEDURE ADDEVENTRESULT
count_add INTEGER;
count_add_aud INTEGER;
count_origen INTEGER;
count_origen_aud INTEGER;
BEGIN
SELECT count (*) FROM INTO count_origen "eventresult" @ koala;
SELECT count (*) FROM INTO count_origen_aud "eventresult_aud" @ koala;
SELECT count (*) FROM INTO count_add eventresult;
SELECT count (*) FROM INTO count_add_aud eventresult_aud;
if (count_add <= 0) THEN
Pgsql_eventresult FOR IN (SELECT * FROM "eventresult" ORDER BY @ koala "binary_data")
LOOP
INSERT INTO eventresult (eventresult.id, eventresult.version, eventresult.binary_data, eventresult.event_id, eventresult.routine_id, eventresult.value)
VALUES (pgsql_eventresult. "id", pgsql_eventresult. "Version", pgsql_eventresult. "Binary_data" pgsql_eventresult. "Event_id" pgsql_eventresult. "Routine_id"
pgsql_eventresult. "value");
END LOOP;
SELECT count (*) FROM INTO count_add eventresult;
END IF;
if (count_add_aud <= 0) THEN
Pgsql_eventresult_aud FOR IN (SELECT * FROM "eventresult_aud" @ koala)
LOOP
INSERT INTO eventresult_aud (eventresult_aud.id, eventresult_aud.rev, eventresult_aud.revtype, eventresult_aud.event_id, eventresult_aud.routine_id, eventresult_aud.value)
VALUES (pgsql_eventresult_aud. "id", pgsql_eventresult_aud. "Rev" pgsql_eventresult_aud. "Revtype" pgsql_eventresult_aud. "Event_id" pgsql_eventresult_aud. "Routine_id"
pgsql_eventresult_aud. "value");
END LOOP;
SELECT count (*) FROM INTO count_add_aud eventresult_aud;
END IF;
Dbms_output.put_line ('Record EVENTRESULT were dropped in,' | | count_add | | 'from' | | count_origen);
Dbms_output.put_line ('Record EVENTRESULT_AUD were dropped in,' | | count_add_aud | | 'from' | | count_origen_aud);
ADDEVENTRESULT END;
Using Oracle 11g
Could anyone help me solve this probema. Thank you very much.