我需要动态创建这个查询:
INSERT INTO "calle" (a, b, c, d)
SELECT l.id_localidad, v.tipovial, v.nomvial, v.geom
FROM "010010001v" AS v,
dblink('dbname=xxx port=xxxx host=xxxxx user=xxx password=xxxxx',
'SELECT id_localidad
FROM "localidadesurbanas"
WHERE cvgeo = ''010010001''')
AS l(id_localidad integer);
唯一改变的是:
...
FROM "010010001v"
...
WHERE cvgeo = ''010010001''')
...
为了:
SELECT tablename
FROM pg_tables
WHERE schemaname = 'public'
AND tablename LIKE '01%v';
"010010001v"
"010010293v"
"010010479v"
...
我希望清楚。如果可能的话,还有学习 PL/pgSQL 的教程。谢谢。