I have table like this:
table a (
id
--
p1 text,
p2 text,
p3 text
)
When I write some function, which use this table, I need to write code like this
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
I want to create a function,
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
in which I will pass "this" instance of current row (I don't know, how it called) and my functions will be like this:
select * from a
where my_function(???) -- what I need to place instead of ???
My questions are:
Can I create function
my_function
like above?If point 1 is true, what type I need to write for parameter? And what I need write on
where
clause?
SELECT version()
helps.) Because it's a good question otherwise.