如何在PostgreSQL的函数中使用(CTE)进行编写
我试图使用“WITH”,这是PostgreSQL函数中的常用表表达式 以下是一个例子: 示例:如何在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
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()