问题
I am trying to create temporary table in my function in postgreSQL. But getting an syntax error. The details as show below in 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 "table".
回答1:
You can only DECLARE variables.
The CREATE TABLE
(ddl) statement can only be run between the BEGIN
- END
blocks.
来源:https://stackoverflow.com/questions/23653139/temporary-table-in-postgresql