Re: Get rid of brackets around variable

Поиск
Список
Период
Сортировка
От Geoff Winkless
Тема Re: Get rid of brackets around variable
Дата
Msg-id CAEzk6ffPv0itkh=cnwXRAugjatYQYANWc9pfbkjL80bNO1mpyQ@mail.gmail.com
обсуждение исходный текст
Ответ на Get rid of brackets around variable  (Raul Kaubi <raulkaubi@gmail.com>)
Ответы Re: Get rid of brackets around variable
Список pgsql-general


On Wed, 5 Feb 2020 at 10:48, Raul Kaubi <raulkaubi@gmail.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

В списке pgsql-general по дате отправления:

Предыдущее
От: Raul Kaubi
Дата:
Сообщение: Get rid of brackets around variable
Следующее
От: "Nick Renders"
Дата:
Сообщение: Unable to startup postgres: Could not read from file "pg_clog/00EC"