[postgis-users] Union a number of tables in a do loop
Shaozhong SHI
shishaozhong at gmail.com
Tue Apr 14 06:15:35 PDT 2020
I have a number of tables called:
temp_table_1
temp_table_2
temp_table_3
temp_table_4
temp_table_5
Can I do something like this?
Do $$
DECLARE
ttb text := 'temp_table_';
counter integer :=1;
i integer :=0;
mystring text;
BEGIN
For counter IN 2..4 LOOP -----22 LOOP
i := counter;
ttb :='temp_table_';
ttb := ttb || i;
---union tables
mystring := 'select * from' || ' temp_table_' || i
' union '
|| 'select * from' || ' temp_table_' || i+1;
End LOOP;
mystring := 'insert into temp_table_1' + mystring;
execute mystring;
END $$;
Can anyone help?
Regards,
Shao
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20200414/f108603e/attachment.html>
More information about the postgis-users
mailing list