Question

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".

Was it helpful?

Solution

You can only DECLARE variables.

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top