0

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

3
  • 1
    You can only declare variables. The CREATE TABLE (ddl) statement can only be run between the BEGIN - END blocks. Commented May 14, 2014 at 11:21
  • @pozs, Oops! Sorry for that. I got it. Thank you so much. Commented May 14, 2014 at 11:23
  • 1
    @pozs Add that as an answer to be accepted by Meem so it does not stay answered. Commented May 14, 2014 at 11:37

1 Answer 1

1

You can only DECLARE variables.

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

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.