I am trying to create a PL / SQL script that retrieves the root "object" along with all its children and other relevant information from an oracle production database. The goal is to create a test data set to recreate production problems. Due to data protection laws, data must be anonymized when retrieving - object names, certain types of identifiers and monetary amounts must be replaced.
I tried to create one or more temporary translation tables that will contain both the original values and anonymous versions. Then I would join the real data with translation tables and give out anonymous values wherever needed.
DECLARE
rootId integer := 123456;
TYPE anonTableRow IS RECORD
(
id NUMBER,
fieldC NUMBER,
anonymizedFieldC NUMBER
);
TYPE anonTable IS TABLE OF anonTableRow;
anonObject anonTable;
BEGIN
FOR cursor_row IN
(
select
id,
fieldC,
1234
from
prodTable
where id = rootId
)
LOOP
i := i + 1;
anonObject(i) := cursor_row;
END LOOP;
FOR cursor_row IN
(
select
prod_table.id,
prod_table.fieldB,
temp_table.anonymizedFieldC fieldC,
prod_table.fieldD
from
prod_table
inner join table(temp_table) on prod_table.id = temp_table.id
where prod_table.id = 123456789
)
LOOP
dbms_output.put_line('INSERT INTO prod_table VALUES (' || cursor_row.id || ', ' || cursor_row.fieldB || ', ' || cursor_row.fieldC || ', , ' || cursor_row.fieldD);
END LOOP;
END;
/
However, I ran into several problems with this approach - it seems almost impossible to combine oracle PL / SQL tables with real database tables. My access to the production database is very limited, so I cannot create global temporary tables, declare types outside of PL / SQL, or anything like that.
My attempt to declare my own PL / SQL types ended with the problems mentioned in this question - the solution does not work for me due to limited permissions.
PL/SQL, - ?
: - , "" .