© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
SupabaseS
Supabase•4y ago•
2 replies
Matthew Ieyoub

IF statements in RPC

Hello all! I'm new to Supabase and wanted to use the SQL editor to create a custom RPC. I'd like to use a conditional inside the function but I keep getting syntax errors. I've tried several options and below is my most recent attempt. Any and all help is appreciated! Thanks.

create or replace function handle_increment_stats (appt_id varchar, status varchar) returns void as $$
    if status = 'Pending'
    begin
      update clinic_stats
      set pending_appointments = pending_appointments + 1
      where id = appt.id
    end
$$ language sql volatile;
create or replace function handle_increment_stats (appt_id varchar, status varchar) returns void as $$
    if status = 'Pending'
    begin
      update clinic_stats
      set pending_appointments = pending_appointments + 1
      where id = appt.id
    end
$$ language sql volatile;
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

Securing Helper Functions in RPC
SupabaseSSupabase / help-and-questions
4d ago
Supabase RPC in Custom Schema
SupabaseSSupabase / help-and-questions
14mo ago
Acceccing authenticated user in rpc() s
SupabaseSSupabase / help-and-questions
4y ago
Combining AND and OR statements
SupabaseSSupabase / help-and-questions
3y ago