3

I am trying to write an SQL Server stored procedure in PostgreSQL. One of the statement is, INSERT INTO @TempTable EXEC(@DynamicQuery) In SQL Server, @DynamicQuery executes and inserts result into @TempTable table variable. I am not finding similar option in PostgreSQL. Can somebody help with any hint please. Thanks.

2
  • 1
    HINT: create table as Commented Jan 13, 2017 at 13:08
  • Will it work with dynamic query with EXECUTE()? Commented Jan 13, 2017 at 13:10

1 Answer 1

7

Your PL/pgSQL line would look similar to the following:

EXECUTE 'CREATE TEMPORARY TABLE mytemp AS ' || dynamicquery;
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.