Skip to content

Latest commit

 

History

History
31 lines (25 loc) · 604 Bytes

prepare-execute.md

File metadata and controls

31 lines (25 loc) · 604 Bytes

Prepare / Execute

You can store a SQL query with prepare.

db=# prepare posts_search as select title from posts limit 5;
PREPARE

Call the method with execute.

db=# execute posts_search;
               title
-----------------------------------
 Hello World!
 My First Pull Request: HAML
 My First Pull Request: Sinatra
 My First Pull Request: Capistrano
 My First Pull Request: SASS
(5 rows)

Deallocate the query with deallocate, and you can set it again.

db=# deallocate posts_search;
DEALLOCATE
db=# prepare posts_search as select title from posts limit 10;
PREPARE