Re: Get rid of brackets around variable

From: Raul Kaubi <raulkaubi(at)gmail(dot)com>
To: Geoff Winkless <pgsqladmin(at)geoff(dot)dj>
Cc: Postgres General <pgsql-general(at)postgresql(dot)org>
Subject: Re: Get rid of brackets around variable
Date: 2020-02-05 11:22:20
Message-ID: CAO_+3-AuoqzkWJpK2s5Xb+XRM13OXv3gOx41NjY72X5tkkfaNA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Awesome, thanks!

Kontakt Geoff Winkless (<pgsqladmin(at)geoff(dot)dj>) kirjutas kuupäeval K, 5.
veebruar 2020 kell 13:11:

>
>
> On Wed, 5 Feb 2020 at 10:48, Raul Kaubi <raulkaubi(at)gmail(dot)com> wrote:
>
>>
>> DO $$
>>> DECLARE
>>> cur cursor for
>>> select * from (values('logi_web'), ('logi_taustaprotsess')) as q (col1);
>>> BEGIN
>>> for i in cur LOOP
>>> RAISE NOTICE 'create table %_y2020m01 PARTITION OF % FOR VALUES FROM
>>> (''2019-12-01'') TO (''2020-01-01'')', i, i;
>>> END LOOP;
>>> END;
>>> $$ LANGUAGE plpgsql;
>>>
>>
>> If I execute, this is the output:
>>
>> NOTICE: create table (logi_web)_y2020m01 PARTITION OF (logi_web) FOR
>>> VALUES FROM ('2019-12-01') TO ('2020-01-01')
>>> NOTICE: create table (logi_taustaprotsess)_y2020m01 PARTITION OF
>>> (logi_taustaprotsess) FOR VALUES FROM ('2019-12-01') TO ('2020-01-01')
>>> DO
>>
>>
> You're returning rows from the cursor.
>
> You need to use i.col1 instead of i.
>
> Geoff
>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Moreno Andreo 2020-02-05 11:45:16 Re: Should I reinstall over current installation?
Previous Message Raul Kaubi 2020-02-05 11:21:44 Declare variable from other variable