On Thu, Apr 27, 2006 at 04:38:35PM -0700, Benjamin Smith wrote:
> I have a customer table (very important) and have numerous fields in other
> tables FK to the serial id of the customer table.
>
> There's an option to delete a customer record, but it has to fail if any
> records are linked to i
This is pretty ugly but you can query pgsql for table attributes...
replace tablename and you'll get the schema for a table including
primary and foreign keys. You could shrink it down and look just
for the foreign key.
SELECT f.attnum AS number, f.attname AS name, f.attnum, f.attnotnull
Benjamin Smith wrote:
I have a customer table (very important) and have numerous fields in other
tables FK to the serial id of the customer table.
What you need is a list of the foreign key definitions, out of which you
build SQL selects that check each child table based on foreign key. T
Forgot to add; another option is to use a PL function with an
exception handler. This may be a bit more elegant approach but not
necessarily easier.
FYI
Jerry Sievers <[EMAIL PROTECTED]> writes:
> Benjamin Smith <[EMAIL PROTECTED]> writes:
>
> > I want to be able to determine in advance whethe
Benjamin Smith <[EMAIL PROTECTED]> writes:
> I want to be able to determine in advance whether or not a record is
> "deleteable" before displaying the button to delete the record. If it's not
> deleteable, it should say so before the user hits the button.
>
> But, the only way that I've been a
I have a customer table (very important) and have numerous fields in other
tables FK to the serial id of the customer table.
There's an option to delete a customer record, but it has to fail if any
records are linked to it (eg: invoices) in order to prevent the books from
getting scrambled.