Re: Dynamic constraint names in ALTER TABLE

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: patrick keshishian <pkeshish(at)gmail(dot)com>
Cc: Adrian Klaver <adrian(dot)klaver(at)gmail(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: Dynamic constraint names in ALTER TABLE
Date: 2011-09-20 03:34:29
Message-ID: 28253.1316489669@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

patrick keshishian <pkeshish(at)gmail(dot)com> writes:
> The question wasn't where does one find the name of the constraint. My
> example demonstrated that I knew how to get that value. The question,
> however, is how do you get that in an ALTER TABLE statement?

You'd need to construct the ALTER statement as a string value and then
EXECUTE it, using a plpgsql function. (In 9.0 you could use a DO
command, but if you want this to also work in 7.4, it'll have to be a
plain old function.)

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message patrick keshishian 2011-09-20 04:21:13 Re: Dynamic constraint names in ALTER TABLE
Previous Message Ondrej Ivanič 2011-09-20 03:23:01 Re: Dynamic constraint names in ALTER TABLE