Re: If operator statements

Поиск
Список
Период
Сортировка
От hubert depesz lubaczewski
Тема Re: If operator statements
Дата
Msg-id 20140123130507.GB14861@depesz.com
обсуждение исходный текст
Ответ на If operator statements  (Elyor Latipov <elyor@outlook.com>)
Список pgsql-bugs
On Thu, Jan 23, 2014 at 12:50:09PM +0500, Elyor Latipov wrote:
> Don't work this statement:
> IF NOT EXISTS (select TRUE from information_schema.constraint_column_usag=
e where constraint_name=3D'projects_pkey')=20
> THEN
>     ALTER TABLE projects ADD CONSTRAINT projects_pkey PRIMARY KEY(id);
> END IF; =20

If you're running it as SQL command (for example in psql session) - it
will not work, as SQL doesn't have "IF" command.
IF is a command in PL/pgSQL, but to use it you have to either make
a function, or use:
DO $$....$$;
sql command.

Best regards,

depesz

--=20
The best thing about modern society is how easy it is to avoid contact with=
 it.
                                                             http://depesz.=
com/

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

Предыдущее
От: deadhead
Дата:
Сообщение: Re: BUG #8869: ip4r93-1.05-3.rhel6 syntax error in ip4r.sql - LANGUAGE 'C' instead of LANGUAGE 'c'
Следующее
От: Marti Raudsepp
Дата:
Сообщение: Re: BUG #8929: Drupal Website not working on Postgres 9.2