ยฉ 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
SupabaseS
Supabaseโ€ข4y agoโ€ข
69 replies
JuicyBenjamin

Syntax error in postgress functions

Hi there, I'm very new to this whole database thing and thought that supabase seemed not so intimidating. I am however running into a problem. I'm following this tutorial https://www.youtube.com/watch?v=I6nnp9AINJk because just like he shows in the video I want to increment a value. I'm pretty sure I've followed the guide to a tee, yet supabase is giving me a syntax error and it's really not that helpful because it's just saying at or around variable name. Maybe one of the more advanced users could point out where the problem occurs ๐Ÿ™
declare
  new_amount int;
begin 
  select amount 
  into new_amount
  from public.collection
  where id = card_id

  new_amount = new_amount + 1;

  update public.collection
  set amount = new_amount
  where id = card_id;

  return new_amount;
end
declare
  new_amount int;
begin 
  select amount 
  into new_amount
  from public.collection
  where id = card_id

  new_amount = new_amount + 1;

  update public.collection
  set amount = new_amount
  where id = card_id;

  return new_amount;
end

I've set the argument to be card_id.

The specific error is: Failed to create function: failed to create pg.functions: syntax error at or near "new_amount"
YouTubeSupabase
Call Postgres functions from JavaScript with RPC
For the introductory video on PostgreSQL functions, check out ๐Ÿ‘‰ https://www.youtube.com/watch?v=MJZCCpCYEqk

Sometimes we have a collection of complex steps we need to perform in a particular sequence from the front-end. Maybe we want to execute an SQL statement that the supabase-js library does not yet support. These are both excellent use case...
Call Postgres functions from JavaScript with RPC
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
Was this page helpful?

Similar Threads

Recent Announcements

Similar Threads

Failed to create pg.functions syntax error...
SupabaseSSupabase / help-and-questions
4y ago
Function syntax error
SupabaseSSupabase / help-and-questions
4y ago
RLS Policy Syntax Error
SupabaseSSupabase / help-and-questions
3y ago
Edge functions error
SupabaseSSupabase / help-and-questions
3y ago
Next page