我正在尝试在pg函数中传递一个文本数组,但我遇到了不同的错误,请帮助我如何传递一个包含文本和整数等不同数据类型的数组....我的代码如下:
CREATE or replace FUNCTION get_data(text[])
RETURNS TABLE(sheet_no text,type text,road_name text,lon text,lat text)
AS $$
DECLARE
sql text;
BEGIN
sql ='set session "myapp.user" ='||$1;
execute sql;
update tbl_encroachment
set landuse = $2
where tbl_encroachment.unique_land_parcel_no = $3
and tbl_encroachment.parcel_sub_division = $4;
RETURN QUERY
select foo.sheet_no,foo.type,foo.road_name,foo.lon,foo.lat
from tbl_encroachment as foo
where foo.unique_land_parcel_no = $3
and foo.parcel_sub_division = $4;
RETURN;
end
$$ LANGUAGE plpgsql;
--execute query
select sheet_no,type,road_name,lon,lat from get_data('{7,hasilpur,7-35-251-0001_1-1-9-SUK_001,9}'::text[])