pg.ddx.io pgsql-bugs@postgresql.org mailing list archive
help / color / mirror / Atom feedIf operator statements
2+ messages / 2 participants
[nested] [flat]
* If operator statements
@ 2014-01-23 07:50 Elyor Latipov <elyor@outlook.com>
0 siblings, 1 reply; 2+ messages in thread
From: Elyor Latipov @ 2014-01-23 07:50 UTC (permalink / raw)
To: pgsql-bugs
Don't work this statement:
IF NOT EXISTS (select TRUE from information_schema.constraint_column_usage where constraint_name='projects_pkey')
THEN
ALTER TABLE projects ADD CONSTRAINT projects_pkey PRIMARY KEY(id);
END IF;
__________________
Best regards,
Elyor.
=
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: If operator statements
@ 2014-01-23 13:05 hubert depesz lubaczewski <depesz@depesz.com>
parent: Elyor Latipov <elyor@outlook.com>
0 siblings, 0 replies; 2+ messages in thread
From: hubert depesz lubaczewski @ 2014-01-23 13:05 UTC (permalink / raw)
To: Elyor Latipov <elyor@outlook.com>; +Cc: 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_usage where constraint_name='projects_pkey')
> THEN
> ALTER TABLE projects ADD CONSTRAINT projects_pkey PRIMARY KEY(id);
> END IF;
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
--
The best thing about modern society is how easy it is to avoid contact with it.
http://depesz.com/
Attachments:
signature.asc (application/pgp-signature, 800B) download
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2014-01-23 13:05 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2014-01-23 07:50 If operator statements Elyor Latipov <elyor@outlook.com>
2014-01-23 13:05 ` hubert depesz lubaczewski <depesz@depesz.com>
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