Temporary table in PostgreSQL

余生颓废 提交于 2019-12-25 02:29:19

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!