Postgresql 带有临时表的Merge语句
当我执行(运行)此过程时,显示以下错误Postgresql 带有临时表的Merge语句,postgresql,Postgresql,当我执行(运行)此过程时,显示以下错误 CREATE OR REPLACE FUNCTION public.merge_test ( r_obj refcursor, _ldeptid character varying ) RETURNS refcursor LANGUAGE 'plpgsql' COST 100.0 VOLATILE AS $function$ BEGIN DROP TABLE IF EXISTS tblCumulate; creat
CREATE OR REPLACE FUNCTION public.merge_test (
r_obj refcursor,
_ldeptid character varying
) RETURNS refcursor
LANGUAGE 'plpgsql' COST 100.0 VOLATILE AS $function$
BEGIN
DROP TABLE IF EXISTS tblCumulate;
create temp table tblCumulate (
lCompid varchar(10),
lOpenCount int default 0,
lClosedCount int default 0
);
DROP TABLE IF EXISTS tblOpen;
create temp table tblOpen (
lOSID SERIAL,
lCount numeric(24,0),
lCompid varchar(100)
);
MERGE into tblCumulate CUM using (select lcompid,lCount from tblopen) as OP
on CUM.lcompid=OP.lcompid
when matched
then update set cum.lOpenCount=op.lcount
when not matched
then insert (lCompid,lOpenCount) values op.lcompid,op.lcount);
open r_obj for
select * from tblCumulate;
return r_obj;
END;
$function$;
PostgreSQL中没有
MERGE
语句
考虑使用。您使用的是第三方PostgreSQL fork或修改版本。请确定您正在使用的确切数据库服务器<代码>选择版本()将是一个良好的开端。
ERROR: "tblcumulate" is not a known variable
LINE 41: MERGE into tblCumulate CUM temp