CALL(7)
โจ CALL โจ
ok bestie so this is from the PostgreSQL 18.6 Documentation โ it's the CALL page (that's CALL(7) if you're being formal ๐
) and it's literally just about invoking procedures. no cap. let's get into it ๐ซถ
๐ธ NAME ๐ธ
CALL โ invoke a procedure ๐
like, you have a procedure? this is how you poke it and make it do the thing.
๐ SYNOPSIS ๐
CALL name ( [ argument ] [, ...] )
that's it. that's the whole vibe. โจ
๐ฆ DESCRIPTION ๐ฆ
okay so CALL executes a procedure. that's the main character energy right there ๐
and here's the tea ๐: if the procedure has any output parameters, then a result row will be returned, containing the values of those parameters. so you do get something back, just not in the way you'd expect from a function. iykyk.
๐ PARAMETERS ๐
nameโ the name of the procedure. it can optionally be schema-qualified, so you can point at exactly which one you mean, no confusion, no drama. ๐ฏargumentโ an argument expression for the procedure call. lowkey the whole point.
arguments can include parameter names, using the syntax name => value. this works exactly the same as in ordinary function calls โ see Section 4.3 for the deets, bestie. ๐
โ ๏ธ okay this part matters: arguments must be supplied for all procedure parameters that lack defaults, includingOUTparameters. BUT โ and this is the iconic bit โ arguments matchingOUTparameters are not evaluated, so it's customary to just writeNULLfor them. (writing something else for anOUTparameter might cause compatibility problems with future PostgreSQL versions, so likeโฆ don't be messy ๐)
๐ฅ NOTES ๐ฅ
- the user must have EXECUTE privilege on the procedure to be allowed to invoke it. no privilege, no party. periodt. ๐
- to call a function (not a procedure), use
SELECTinstead. different tool, different slay. โจ - if
CALLis executed inside a transaction block, then the called procedure cannot execute transaction control statements. those are only allowed ifCALLis executed in its own transaction. so like, pick a lane bestie ๐ญ - PL/pgSQL handles output parameters in
CALLcommands differently โ see Section 41.6.3. yes, it's giving chaotic, but it's documented, so we move. ๐
โญ EXAMPLES โญ
CALL do_db_maintenance();
look at her go. iconic. ๐
๐ COMPATIBILITY ๐
CALL conforms to the SQL standard โ except for the handling of output parameters. the standard says that users should write variables to receive the values of output parameters. so we're doing our own thing there, and that's fine, we're built different. ๐ง
๐ SEE ALSO ๐
CREATE PROCEDURE (CREATE_PROCEDURE(7))
k that's the whole page bestie!! ๐ this was PostgreSQL 18.6, dated 2026, and the page is CALL(7). go call a procedure, you got this ๐ซถโจ๐
๐ฆ where this page comes from
- opensuse-leap 16.0: postgresql18 18.6-160000.1.1 ยท PostgreSQL
- opensuse-leap 16.0: postgresql18 18.6-160000.1.1 ยท PostgreSQL
- opensuse-leap 16.0: postgresql18 18.6-160000.1.1 ยท PostgreSQL
- opensuse-leap 16.0: postgresql18 18.6-160000.1.1 ยท PostgreSQL
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms