EXECUTE(7)
β¨ EXECUTE(7) β¨
okay so bestie, this is literally the page for the EXECUTE command in PostgreSQL 13.23 and it's giving "run that prepared statement you made earlier" vibes π
πΈ NAME πΈ
EXECUTE β run a prepared statement, no cap. literally its whole job π«Ά
π SYNOPSIS π
EXECUTE name [ ( parameter [, ...] ) ]
π DESCRIPTION π
so EXECUTE is what you use to run a statement you already prepped earlier. but here's the tea: prepared statements only exist for the duration of a session, bestie π so the statement you're trying to execute must have been created by a PREPARE statement that you ran earlier in the current session. like, same session only. periodt.
if the PREPARE statement that created your statement specified some parameters, then you must pass a compatible set of parameters to the EXECUTE statement β or else an error gets raised, and not in a cute way π
β οΈ heads up bestie: unlike functions, prepared statements are not overloaded based on the type or number of their parameters. so the name of a prepared statement has to be unique within a database session. one name, one statement, no sharing, iykyk π
for more info on how to create and use prepared statements, go check PREPARE(7) β it's the prequel to this whole saga π¦
π§ PARAMETERS π§
nameβ the name of the prepared statement you wanna execute. that's it, that's the name πparameterβ the actual value of a parameter for your prepared statement. this needs to be an expression that yields a value compatible with the data type of this parameter, as it was determined when the prepared statement was created. so like, match the vibes of the type you declared, bestie β¨
π₯ OUTPUTS π₯
the command tag that EXECUTE returns? it's the command tag of the prepared statement, not the tag of EXECUTE. plot twist, but make it make sense πβ¨
π EXAMPLES π
examples are literally given in the Examples section of the PREPARE(7) documentation β go look there, bestie, they ate π
β COMPATIBILITY β
the SQL standard does include an EXECUTE statement, but it's only for use in embedded SQL. this version of the EXECUTE statement also uses a somewhat different syntax. so like, close but not identical β don't @ me π
π SEE ALSO π
and that's the whole page, bestie!! π written by the PostgreSQL 13.23 girlies, dated 2025, and EXECUTE(7) is slaying as always π
β¨
π¦ where this page comes from
- opensuse-leap 16.0: postgresql13 13.23-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql13 13.23-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql13 13.23-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql13 13.23-160000.1.1 Β· PostgreSQL
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms