RPC Call Returns Zero Rows But Function Works as Expected

I'm using a function to return user profile data. When using the function in the SQL editor, it returns the proper information. But when using RPC, it doesn't work out, and the return data array is empty.

CREATE OR REPLACE FUNCTION fetch_user_details(usersid uuid)
RETURNS table(
user_detail_id bigint, 
user_id uuid, 
full_name text,
user_email text,
org_id bigint, 
org_name text
) AS
$$
BEGIN 
   RETURN QUERY
   SELECT 
   u.id, 
   u.user_id,
   u.full_name,
   u.user_email,
   o.id,
   o.org_name

   FROM user_details u
   INNER JOIN org_details o
   ON u.org_id = o.id
   WHERE u.user_id = usersid;
   END
$$
language plpgsql;
Was this page helpful?