kaushalparik27
kaushalparik27

Reputation: 804

Insert INTO Temp Table result of dynamic query in PostgreSQL

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.

Upvotes: 3

Views: 4891

Answers (1)

Laurenz Albe
Laurenz Albe

Reputation: 246483

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

EXECUTE 'CREATE TEMPORARY TABLE mytemp AS ' || dynamicquery;

Upvotes: 7

Related Questions