From: Ron <ronljohnsonjr@gmail.com>
To: pgsql-general <pgsql-general@postgresql.org>
Subject: Syntax checking DO blocks and ALTER TABLE statements?
Date: Tue, 16 Feb 2021 16:42:56 -0600
Message-ID: <ef0b6d3f-e351-2aef-b09d-3f817cf83269@gmail.com> (raw)
How does one go about syntax checking this?
do $$
begin if exists (select 1 from information_schema.table_constraints
where constraint_name = 'error_to_web_service_error') then
raise notice 'EXISTS error_to_web_service_error';
else
ALTER TABLE web_service_error
ADD CONSTRAINT error_to_web_service_error FOREIGN KEY (error_id)
REFERENCES error_code(error_id)
ON DELETE NO ACTION NOT DEFERRABLE INITIALLY IMMEDIATE;
end if
end $$
(There are 222 ALTER TABLE ADD FOREIGN KEY statements that I'm wrapping in
similar DO blocks, and want to make sure the statements are clean.)
--
Angular momentum makes the world go 'round.
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: ronljohnsonjr@gmail.com
Subject: Re: Syntax checking DO blocks and ALTER TABLE statements?
In-Reply-To: <ef0b6d3f-e351-2aef-b09d-3f817cf83269@gmail.com>
References: <ef0b6d3f-e351-2aef-b09d-3f817cf83269@gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
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