-1
我需要動態地創建此查詢:PostgreSQL的動態SQL查詢
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。 謝謝。
最好的pl/pgsql教程是Postgres文檔本身... –
Postgresql版本? –