我有 PostgreSQL 8.4 和 3 对这样的表:
CREATE TABLE filedata_temp
(
num serial NOT NULL,
id integer,
mydata character(25),
the_geom geometry,
CONSTRAINT filedata_temp_pkey PRIMARY KEY (num)
)
CREATE TABLE filedata
(
num serial NOT NULL,
id integer,
mydata character(25),
the_geom geometry,
CONSTRAINT filedata_pkey PRIMARY KEY (num)
)
和3个这样的功能:
-- Function: insert_into_wgs()
-- DROP FUNCTION insert_into_wgs();
CREATE OR REPLACE FUNCTION insert_into_wgs()
RETURNS void AS
$BODY$
BEGIN
INSERT INTO filedata (num,id,mydata,the_geom)
SELECT num,id,mydata,ST_TRANSFORM(the_geom,4326)
FROM filedata_temp
WHERE id NOT IN (SELECT id FROM filedata);
end;
$BODY$
LANGUAGE plpgsql VOLATILE
COST 100;
ALTER FUNCTION insert_into_wgs() OWNER TO postgres;
);
所以我有 3 对表的 3 个模拟函数。这样不好。那么我可以为所有 3 对创建一个函数吗?这个怎么做?