Allow changing case of keywords, table names, and column names and modifying template for resulting script
When exporting data to SQL format (INSERT, UPDATE, MERGE):
Allow changing the case of keywords, table names, and column names.
Allow modifying the template for the resulting script.
The template should be applied to every exported row and should have the text containing keys instead of which the values from exported rows are inserted. In the examples below the keys have the format :ColumnName
Let's assume, we're exporting data to the MERGE format.
The "testtable" contains:
col1 col2 col3 col4
r1c1 r1c2 r1c3 r1c4
r2c1 r2c2 r2c3 r2c4
r3c1 r3c2 r3c3 r3c4
The system generates the following template:
MERGE INTO "testtable" USING DUAL ON (COL1 = :COL1)
WHEN MATCHED THEN UPDATE SET COL2 = :COL2, COL3 = :COL3, COL4 = :COL4
WHEN NOT MATCHED THEN INSERT (COL1 , COL2 , COL3, COL4) VALUES
(:COL1, :COL2 , :COL3, :COL4);
It's hardly readable and may not correspond to corporate policies for formatting scripts.
A user should be able to change it to:
-- ':col1' - is ===:col2===
prompt <:col1>
merge into "testtable" using dual on (col1 = :col1)
..when matched then
....update set
......col2 = :col2, col3 = :col3, col4 = :col4
..when not matched then
....insert (col1 , col2 , col3, col4)
....values (:col1, :col2, :col3, :col4);
or even (into several target tables):
-- ':col1' - inserting a row into the main table
merge into "myTable1" using dual on (col1 = :col1)
..when matched then
....update set col2 = :col2
..when not matched then
....insert (col1 , col2)
....values (:col1, :col2);
-- myTable11 ':col1', ':col2' - inserting a row into the subordinate table "myTable11"
merge into "myTable1_1" using dual on (col1 = :col1 and col2 = :col2)
..when matched then
....update set col3 = :col3
..when not matched then
....insert (col1 , col2 , col3)
....values (:col1, :col2, :col3);
-- myTable12 ':col1' - inserting a row into the subordinate table "myTable12"
merge into "myTable1_2" using dual on (col1 = :col1)
..when matched then
....update set col3 = :col3, col4 = :col4
..when not matched then
....insert (col1 , col2 , col3, col4)
....values (:col1, :col2, :col3, :col4);
What does it need for?
To ease maintaining production DBs.
For instance, a dictionary was changed and needs to be updated.
Filling a test DB with data and exporting to the script - it will be a patch.
Applying the patch to the production DB.