© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
SupabaseS
Supabase•3y ago•
17 replies
Jota

postgres function help

Hello! Im trying to do something like this;

DO $$
DECLARE
id INTEGER;
BEGIN
-- Set the role to 'postgres'
SET ROLE postgres;

-- Your SQL statements go here
SELECT tenant_id INTO id FROM users WHERE id = auth.uid();

-- Reset the role to the original user
RESET ROLE;

-- Return the result
RETURN id;
END $$;

but it keep returning syntax error, what should I do?
image.png
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

Need help with postgres function
SupabaseSSupabase / help-and-questions
4y ago
Helper postgres function `safe_auth_json`
SupabaseSSupabase / help-and-questions
4y ago
Postgres Help
SupabaseSSupabase / help-and-questions
5w ago
Postgres Help
SupabaseSSupabase / help-and-questions
5w ago