Postgres - Using a temp table created in one function, to use in another

pvsbandi used Ask the Experts™

   In DB2, we can declare a temporary table in a Stored Procedure SP1 and use it in another stored procedure SP2, while calling SP1.

Is there a way to do it in Postgresql 9.7?
Please help with an example, if there's a way to it?
Thanks a lot!
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
SharathData Engineer

I don't think its possible in Postgres.
Temporary tables are automatically dropped at the end of a session, or optionally at the end of the current transaction.
Optionally, GLOBAL or LOCAL can be written before TEMPORARY or TEMP. This presently makes no difference in PostgreSQL and is deprecated; see Compatibility.

If possible, create a permanent table and use it across procs.


Thanks Sharat!
 Permanent table may get locked every now and then, because these SPs get called for each person and there will be many persons in the application.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial