小编And*_*rov的帖子

where 子句中的 PostgreSQL 函数

我有这样的表:

table a (
   id 
   --
   p1 text,
   p2 text,
   p3 text
)
Run Code Online (Sandbox Code Playgroud)

当我编写一些使用该表的函数时,我需要编写这样的代码

create or replace function ...

select * from a
   where a.p1 is not null
     and a.p2 is not null
     and a.p3 is not null
Run Code Online (Sandbox Code Playgroud)

我想创建一个函数,

 create function my_function(??? val) returns boolean as -- what I need to place instead of ???
 $$
 begin
     return val.p1 is not null 
        and val.p2 is not null
        and val.p3 is not null;
 end;
 $$ language plpgsql
Run Code Online (Sandbox Code Playgroud)

其中我将传递当前行的“this”实例(我不知道它是如何调用的),我的函数将如下所示:

select * from …
Run Code Online (Sandbox Code Playgroud)

postgresql functions

1
推荐指数
1
解决办法
2456
查看次数

标签 统计

functions ×1

postgresql ×1