RCP Call
Input Parameters
| Parameter | Variable | Required | Description |
| Function Name | {{functionName}} | Yes | Name of the RPC function to call |
| Body Payload | {{bodyPayload}} | Yes | JSON string with function parameters |
Output
| Output | Variable | Description |
| RPC Result | {{rpcResult}} | Result returned by the function |
| Success | {{success}} | Boolean indicating if the call succeeded |
Creating RPC Functions
Before using the RPC Call stage, you need to create functions in Supabase. Here are some examples:
Example 1: Get Records in Multiple Categories
Find IDs that exist in ALL specified categories:
CREATE OR REPLACE FUNCTION get_items_in_all_categories(category_ids int[])
RETURNS TABLE(item_id bigint) AS $$
BEGIN
RETURN QUERY
SELECT i.item_id FROM items i
WHERE i.category_id = ANY(category_ids)
GROUP BY i.item_id
HAVING COUNT(DISTINCT i.category_id) = array_length(category_ids, 1);
END;
$$ LANGUAGE plpgsql;
Example 2: Get Categories by Item ID
Find all categories for a specific item:
CREATE OR REPLACE FUNCTION get_categories_by_item(item_id_input bigint)
RETURNS TABLE(category_id bigint) AS $$
BEGIN
RETURN QUERY
SELECT i.category_id::bigint FROM items i
WHERE i.item_id = item_id_input;
END;
$$ LANGUAGE plpgsql;
Usage Examples
Example 1: Find Items in Multiple Categories
| Parameter | Value |
| functionName | get_items_in_all_categories |
| bodyPayload | "{\"category_ids\": [1, 2, 3]}" |
Result: Returns all item_ids that exist in ALL three categories
Example 2: Get Categories for an Item
| Parameter | Value |
| functionName | get_categories_by_item |
| bodyPayload | "{\"item_id_input\": 123}" |
Result: Returns all category IDs associated with item 123
Important Notes
- Functions must be created in Supabase SQL Editor first
- Use bigint for IDs to avoid type mismatch errors
- Parameter names in bodyPayload must match function parameter names exactly
- Great for complex queries: aggregations, joins, intersections