CREATE OR REPLACE FUNCTION core.get_purchase_account_id(_item_id integer)
RETURNS integer
LANGUAGE plpgsql
AS $function$
BEGIN
RETURN
purchase_account_id
FROM core.item_groups
INNER JOIN core.items
ON core.item_groups.item_group_id = core.items.item_group_id
WHERE core.items.item_id = $1;
END
$function$