-
I'm trying to create a trigger/function that runs an Edge Function. Everything is great but for the life of me I cannot get it to get the data from public.users.primary_currency This is my code: `CREATE OR REPLACE FUNCTION fetch_exchange_rate_on_insert() -- Fetch the primary_currency from the users table -- Log the fetched primary_currency -- If no primary_currency is found, log an error -- Check if the account currency is different from the user's primary_currency
ELSE RETURN NEW; CREATE TRIGGER fetch_exchange_rate_trigger If I do this:
I can get the correct value "usd" from my database. However, my code above always exits on the first RAISE EXCEPTION because there is no user_primary_currency, leading me to believe I'm doing this wrong:
However, the schema is correct, permission seems to be correct since I'm running as the postgre role. What's wrong? Some help would be appreciated |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
I simply had to do ALTER FUNCTION fetch_exchange_rate_on_insert() SECURITY DEFINER; |
Beta Was this translation helpful? Give feedback.
I simply had to do
ALTER FUNCTION fetch_exchange_rate_on_insert() SECURITY DEFINER;