· 9 years ago · Nov 19, 2016, 02:54 PM
1;
2do
3$$
4DECLARE var_table_name character varying(1000);
5var_cnt bigint;
6begin
7 drop table if exists temp_tables;-- ( character varying(1000), bigint);
8
9 create temp table if not exists temp_tables (table_name character varying(1000), cnt bigint);
10 truncate table tt_tables;
11
12 for var_table_name in select table_name from information_schema.tables tt where tt.table_schema = 'tempdownload' loop
13 insert into temp_tables(table_name)
14 select var_table_name;
15 end loop;
16
17 for var_table_name in select table_name from temp_tables loop
18 execute 'select count(*) from tempdownload."'||var_table_name||'";'
19 into var_cnt;
20
21 raise notice 'processing table tempdownload."%"',var_table_name;
22
23 update temp_tables
24 set cnt = var_cnt
25 where
26 temp_tables.table_name = var_table_name;
27 end loop;
28end;
29$$
30language 'plpgsql';