© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
SupabaseS
Supabase•4y ago•
13 replies
lewisd

Newb here, does anybody have experience with checking if a row exists in a db function?

Hi guys.

This is my current function (This function will basically increment a score between users):

create function increment_kudos (giver_id uuid, receiver_id uuid, amount int)
returns void as
$$
  update "userKudos"
  set kudos = kudos + amount
  where "giverId" = giver_id AND "receiverId" = receiver_id
$$
language sql volatile;
create function increment_kudos (giver_id uuid, receiver_id uuid, amount int)
returns void as
$$
  update "userKudos"
  set kudos = kudos + amount
  where "giverId" = giver_id AND "receiverId" = receiver_id
$$
language sql volatile;


Problem is, the row needs to exist first if it is able to increment it.

Im quite new so im unsure of syntax regarding how to add this logic in
sql
sql
. Does anyone have any tips?
Supabase banner
SupabaseJoin
Supabase gives you the tools, documentation, and community that makes managing databases, authentication, and backend infrastructure a lot less overwhelming.
45,816Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Checking if a row with the same element already exists
SupabaseSSupabase / help-and-questions
4y ago
Is there a simple way of checking if a row exists
SupabaseSSupabase / help-and-questions
14mo ago
Check if row already exists with RLS.
SupabaseSSupabase / help-and-questions
4y ago
Checking role in edge function
SupabaseSSupabase / help-and-questions
4y ago