Re: Tempory table is not getting created inside Function in postgres.

From: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
To: nikhil raj <nikhilraj474(at)gmail(dot)com>
Cc: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: Tempory table is not getting created inside Function in postgres.
Date: 2023-02-27 20:01:15
Message-ID: 94be2c64-8392-e804-28ce-ab3e16dce4d1@aklaver.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 2/27/23 11:52 AM, nikhil raj wrote:

Reply to list also
Ccing list.

> HI Adrian,
>
>  Yes, I have tried it through the same error.
>
> Orion_db=> select api."post_publish_Roster"()
> Orion_db -> ;
> ERROR:  relation "roster_table" does not exist
> LINE 94: ...           interval '1 day')::date as d_date FROM roster_tab...
>                                                               ^
> QUERY:
>
> drop table if exists roster_table;
> create temp table roster_table as
> SELECT roster_id, link_id, paynumber, username, line_position,
>  crewname,weeknumber,weekstartdate,weekenddate
>         FROM crew_links.links_map
>         CROSS JOIN LATERAL get_weeks( '2023-02-12', '2023-03-04') AS
> weekdata
>         WHERE roster_id=234 and weekdata.weeknumber in (select
> min(weeknumber) from  get_weeks('2023-02-12', '2023-03-04') );
>
>         DO $$
> DECLARE

I missed it the first time, you are embedding a DO inside the function.

1) Pretty sure that is not going to work. Especially as you are changing
languages.

2) Why are you doing that?

3) Either incorporate everything into one function or create separate
stand alone function for the DO portion and use that in the
post_publish_Roster

--
Adrian Klaver
adrian(dot)klaver(at)aklaver(dot)com

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2023-02-27 20:04:31 Re: Tempory table is not getting created inside Function in postgres.
Previous Message Adrian Klaver 2023-02-27 19:47:56 Re: Tempory table is not getting created inside Function in postgres.