And, interesting to note that using triggers within pocketbase isn't well supported because they do a dry run insert to check against constraints and then delete it if the constraint fails.
https://github.com/pocketbase/pocketbase/discussions/650#dis...
I mention this because the OP inquired about stored procedures, somewhat related.
Still, pocketbase is so amazing.