我創建了一個動態函數。我動態地獲取表名的一部分。該功能已成功創建。但是當我執行該功能。我收到一個錯誤。我怎麼解決這個問題?我打電話跟Postgresql函數動態表quote_ident錯誤
select * from dwgcould.getlatlngcenter(2000653);
CREATE OR REPLACE FUNCTION dwgcould.getlatlngcenter(IN pro_id integer,
OUT lat_center double precision, OUT lng_center double precision)
AS $$
BEGIN
EXECUTE 'SELECT st_x(st_centroid(st_transform(geom,4326))) as lng_center ,st_y(st_centroid(st_transform(geom,4326))) as lat_center
FROM dwgcould.adpes_v1_' || quote_ident(pro_id) || '_line limit 1';
END;
$$ LANGUAGE plpgsql;
功能的錯誤代碼是
ERROR: function quote_ident(integer) does not exist LINE 2: FROM dwgcould.adpes_v1_' || quote_ident(pro_id) || '_line... ^ HINT: No function matches the given name and argument types. You might need to add explicit type casts. QUERY: SELECT 'SELECT st_x(st_centroid(st_transform(geom,4326))) as lng_center ,st_y(st_centroid(st_transform(geom,4326))) as lat_center FROM dwgcould.adpes_v1_' || quote_ident(pro_id) || '_line limit 1' CONTEXT: PL/pgSQL function dwgcould.getlatlngcenter(integer) line 4 at EXECUTE statement ********** Error ********** ERROR: function quote_ident(integer) does not exist SQL state: 42883 Hint: No function matches the given name and argument types. You might need to add explicit type casts. Context: PL/pgSQL function dwgcould.getlatlngcenter(integer) line 4 at EXECUTE statement
此外,我如何檢查表是否存在?
'如果(選擇從pg_tables計數(1)其中,表名= 'TN')<1然後...' –