EXECUTE(7)

πŸ“¦ version 13.23, in opensuse-leap 16.0

✨ 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