I have written this function:
create function check_same_price() returns integer as $result$
declare
result integer;
begin
set res = (select *
from (select count(distinct title), price_dvd_buy
from dvd_to_buy
group by price_dvd_buy) as dummy
where count>1);
if (res==none) then result=0;
else result=1;
end if;
end;
$result$ language plpgsql;
the function returns 0 if there is the same price for same title, otherwise it returns 1. This check is done because I want the same price for the same film; I'm using phppgadmin to manage it. I receive this error:
SQL error:
ERROR: error of sintax to or near "("
LINE 5: set res = (select *
What's wrong, I don't know to fix it. Thanks!
setin PL/pgSQL. Please read the manual: postgresql.org/docs/current/static/…