create or replace function increment_referral_earnings(
p_wallet text,
p_amount numeric
)
returns void as $$
begin
update public.users
set
total_earned = total_earned + p_amount,
total_referrals = total_referrals + 1,
updated_at = now()
where wallet_address = p_wallet;
end;
$$ language plpgsql security definer;
GRANT EXECUTE ON FUNCTION increment_referral_earnings(
p_wallet text,
p_amount numeric
) TO authenticated;
select * from rpc('increment_referral_earnings, {"p_wallet": "TEST", "p_amount": 1}');
Giving me ERROR: 42883: function rpc(unknown) does not exist in the Editor and PostgREST; error=42703 in the API Gateway
Must be missing something here.
It's created in the public schema, I can see it as a function in the DB manager and I have looked into the API docs, seems all good in there.