building stored proc in Postgresql
Budget: $10 – $30 USD
Hi,
I want to write a stored procedure in postgresql to compare some unapproved schema to an approved schema and check if there is any new table added or the data type is same etc which are present in information schema. I want to implement cursors with stored proc in order to iterate the result set table by table. How can I do that?
Ex: I want to implement this code under stored procedure to automate the process
select COALESCE(c1.table_name, c2.table_name) as table_name,
COALESCE(c1.column_name, c2.column_name) as table_column,
c1.column_name as schema1,
c2.column_name as schema2
from
(select table_name,
column_name
from information_schema.columns c
where c.table_schema = 'schema1') c1
full join
(select table_name,
column_name
from information_schema.columns c
where c.table_schema = 'schema2') c2
on c1.table_name = c2.table_name and c1.column_name = c2.column_name
where c1.column_name is null
or c2.column_name is null
order by table_name,
table_column;
I want to write a stored procedure in postgresql to compare some unapproved schema to an approved schema and check if there is any new table added or the data type is same etc which are present in information schema. I want to implement cursors with stored proc in order to iterate the result set table by table. How can I do that?
Ex: I want to implement this code under stored procedure to automate the process
select COALESCE(c1.table_name, c2.table_name) as table_name,
COALESCE(c1.column_name, c2.column_name) as table_column,
c1.column_name as schema1,
c2.column_name as schema2
from
(select table_name,
column_name
from information_schema.columns c
where c.table_schema = 'schema1') c1
full join
(select table_name,
column_name
from information_schema.columns c
where c.table_schema = 'schema2') c2
on c1.table_name = c2.table_name and c1.column_name = c2.column_name
where c1.column_name is null
or c2.column_name is null
order by table_name,
table_column;
Related categories:
PostgreSQL