pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: nikhil raj <nikhilraj474@gmail.com>
Cc: pgsql-general@postgresql.org
Subject: Re: Tempory table is not getting created inside Function in postgres.
Date: Mon, 27 Feb 2023 15:04:31 -0500
Message-ID: <413922.1677528271@sss.pgh.pa.us> (raw)
In-Reply-To: <CAG1ps1xOa8W3Q2T=6Tskrq2s0jPdAsaJv1-efo53Je5fvAuh0A@mail.gmail.com>
References: <CAG1ps1xOa8W3Q2T=6Tskrq2s0jPdAsaJv1-efo53Je5fvAuh0A@mail.gmail.com>

nikhil raj <nikhilraj474@gmail.com> writes:
> This is the Function I have created successfully but while executing it
> throughs an error temp table doesn't exist.

You won't be able to do it like that in a SQL-language function, because
the whole function body is parsed and parse-analyzed in one go.  So the
later query referencing ROSTER_TABLE fails because it's parsed before
the CREATE TABLE executes.  (Improving that has been on the to-do list
for a couple of decades, so don't hold your breath...)  I suggest putting
the whole thing, not just part of it, into plpgsql.

			regards, tom lane





view thread (7+ messages)  latest in thread

Message-ID: <413922.1677528271@sss.pgh.pa.us>
Permalink:  ../413922.1677528271@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/413922.1677528271@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: tgl@sss.pgh.pa.us, nikhilraj474@gmail.com
  Subject: Re: Tempory table is not getting created inside Function in postgres.
  In-Reply-To: <413922.1677528271@sss.pgh.pa.us>
  References: <CAG1ps1xOa8W3Q2T=6Tskrq2s0jPdAsaJv1-efo53Je5fvAuh0A@mail.gmail.com> <413922.1677528271@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox