我有下面的表和记录,我必须将表名("LandXML_QCC_ParcelMarks"
,"LandXML_QCC_ParcelInformation"
)作为输入参数(tblparcelmarks
,tblparcelinfo
)传递给以下函数。
我如何在以下函数的查询中使用此表名参数。我试过了,但是没有用。
create table "LandXML_QCC_ParcelMarks"("DPID" TEXT,"From" TEXT,"Name" Text);
insert into "LandXML_QCC_ParcelMarks" values('1','ram','kumar');
create table "LandXML_QCC_ParcelInformation"("DPID" TEXT,"Pntref" Text);
insert into "LandXML_QCC_ParcelInformation" values('1','ram');
CREATE OR REPLACE FUNCTION public.getparcelnonparcelfinal(planid text, tblparcelmarks text, tblparcelinfo text)
RETURNS text AS
$BODY$
declare
tblmark RECORD;
parCount integer;
parNonCount integer;
totalParNonCount text;
tblCou integer;
begin
parCount = 0;
parNonCount = 0;
FOR tblmark IN (SELECT "From", "Name" FROM tblParcelMarks where "DPID" = planid) LOOP
SELECT COUNT(*) into tblCou FROM tblParcelInfo where "DPID" = PlanID and ("Pntref" like '%' || tblMark."From" || ',' || CAST(tblMark."Name" As text) || '%' or "Pntref" like '%' || CAST(tblMark."Name" As text) || ',' || tblMark."From" || '%');
IF tblCou > 0 THEN
parCount = parCount + 1;
ELSE
parNonCount = parNonCount + 1;
END IF;
END LOOP;
totalParNonCount = CAST(parCount As text) || ',' || CAST(parNonCount As text);
return totalParNonCount;
end;
$BODY$
LANGUAGE plpgsql;