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
_______________________________________________
postgis-users mailing list
[email protected]
https://lists.osgeo.org/mailman/listinfo/postgis-users

Reply via email to