Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/linq/3.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的函数中使用(CTE)进行编写_Postgresql_Common Table Expression - Fatal编程技术网

如何在PostgreSQL的函数中使用(CTE)进行编写

如何在PostgreSQL的函数中使用(CTE)进行编写,postgresql,common-table-expression,Postgresql,Common Table Expression,我试图使用“WITH”,这是PostgreSQL函数中的常用表表达式 以下是一个例子: 示例: Create or replace function withFunction() returns void as $Body$ Begin WITH cmn_l1 AS ( SELECT "PhoneNumber1","PhoneNumber2", DENSE_RANK() OVER(Partition by "PhoneNumber1" Order By "Pho

我试图使用“WITH”,这是PostgreSQL函数中的常用表表达式

以下是一个例子:

示例

 Create or replace function withFunction() returns void as
 $Body$
 Begin
  WITH cmn_l1
  AS
  (
    SELECT "PhoneNumber1","PhoneNumber2",
    DENSE_RANK() OVER(Partition by "PhoneNumber1" Order By "PhoneNumber2" )FoundIn
    From tablename;
  )
 SELECT DISTINCT * INTO temptable
 FROM cmn_l1
 WHERE FoundIn > 1;

 end;
 $Body$
 language plpgsql;

问题:如何使用WITH IN函数执行并将值输入上表

有必要返回

Create or replace function withFunction()
returns table(phone1 text, phone2 text) as
然后


可以因此,在使用@Meem
EXECUTE
用于动态sql和
PERFORM
之前不需要给出EXECUTE或EXECUTE语句,如果您不想返回select@CLODALDO Neto的结果,这是绝对正确的。非常感谢你。
select * from withFunction()