Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/jpa/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Postgresql 带有临时表的Merge语句_Postgresql - Fatal编程技术网

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