Home / Learn Secure SQL / The Stored-Procedure-Only Access Pattern
The Stored-Procedure-Only Access Pattern
An account that can only call specific procedures, nothing else directly.
How to think about this
Definition
In this pattern, an account is granted EXECUTE on a specific set of stored procedures/functions, but no direct SELECT/INSERT/UPDATE/DELETE on the underlying tables at all — every interaction must go through an approved procedure.
Why you need this
This centralises and constrains exactly what operations are possible, which can be valuable for especially sensitive tables, at the cost of extra development overhead for every new kind of query.
How it works
Grant EXECUTE on a curated set of procedures only; revoke direct table access entirely for that account, and write new procedures (with their own safe, parameterised internals, as covered earlier) as new needs arise.
Where you'll see this
- Web application code review
- Backend development
- Database administration
REVOKE ALL ON accounts FROM teller_app;
GRANT EXECUTE ON FUNCTION transfer_funds(int, int, numeric) TO teller_app;
-- teller_app can only ever call transfer_funds(...), never query accounts directlyTest what you just read
1. In the stored-procedure-only pattern, an account typically has...
Procedures only, nothing direct.