My version of Postgres is:
"PostgreSQL 9.4.4, compiled by Visual C++ build 1800, 32-bit"
Let's say I have two tables Table1
and Table2
, which are having column col1
and col2
respectively.
CREATE TABLE Table1(col1 int);
CREATE TABLE Table2(col2 int);
There is another table Table3
storing a formula for migrating data from Table1
to Table2
:
CREATE TABLE Table3 (
tbl_src varchar(200),
col_src varchar(500),
tbl_des varchar(200),
col_des varchar(100),
condition varchar(500)
);
INSERT INTO Table3 (tbl_src, col_src, tbl_des, col_des, condition)
SELECT 'Table1','col1','Table2','col2',NULL
How to compile this formula in a dynamic query and insert into the destination table?