Temporary table in PostgreSQL

I am trying to create a temporary table in my function in postgreSQL. But get a syntax error. Details as below example:

Example:

Create or replace function testing(a varchar(100),b varchar(100)) returns setof record as $$ Declare create temp table testtable(x int, y int identity(1,1), z varchar(100)); .... 

Error: syntax error at or near the table.

0
source share
1 answer

You can use DECLARE .

The CREATE TABLE (ddl) statement can only be executed between BEGIN - END blocks.

+1
source

Source: https://habr.com/ru/post/1245339/


All Articles