Re: [GENERAL] How to replace rows in table so that foreign key rows

2006-04-21 Thread Stephan Szabo
On Thu, 20 Apr 2006, Stephan Szabo wrote: On Thu, 20 Apr 2006, Andrus wrote: I want to replace ( delete and insert) records in master table . I delete and insert record with same primary key. I want that foreign key records are not deleted. I tried begin; create temp table t1 (

Re: [GENERAL] How to replace rows in table so that foreign key rows

2006-04-21 Thread Andrus
... and there doesn't appear (for non-match partial constraints) seem to be a special case for the referenced row coming back into existance as far as I can tell either. Or, if you're willing to patch, I think a first order approximation of what you want might be to remove the special cases

Re: [GENERAL] How to replace rows in table so that foreign key rows

2006-04-21 Thread Stephan Szabo
On Fri, 21 Apr 2006, Andrus wrote: ... and there doesn't appear (for non-match partial constraints) seem to be a special case for the referenced row coming back into existance as far as I can tell either. Or, if you're willing to patch, I think a first order approximation of what you

[GENERAL] How to replace rows in table so that foreign key rows are not deleted

2006-04-20 Thread Andrus
I want to replace ( delete and insert) records in master table . I delete and insert record with same primary key. I want that foreign key records are not deleted. I tried begin; create temp table t1 ( pk integer primary key ); insert into t1 values(1); create temp table t2 (fk integer ); alter

Re: [GENERAL] How to replace rows in table so that foreign key rows

2006-04-20 Thread Berend Tober
Andrus wrote: Is there any generic way to turn off foreign key constraints before delete command in transaction ? From TFM: --disable-triggers This option is only relevant when performing a data-only restore. It instructs pg_restore to execute commands to temporarily disable triggers on the

Re: [GENERAL] How to replace rows in table so that foreign key rows

2006-04-20 Thread Andrus
I did so, and for a table named 'country' the following SQL statements were produced: -- Disable triggers UPDATE pg_catalog.pg_class SET reltriggers = 0 WHERE oid = 'country'::pg_catalog.regclass; /* COPY command goes here to bulk load table data. */ -- Enable triggers UPDATE

Re: [GENERAL] How to replace rows in table so that foreign key rows

2006-04-20 Thread Stephan Szabo
On Thu, 20 Apr 2006, Andrus wrote: I want to replace ( delete and insert) records in master table . I delete and insert record with same primary key. I want that foreign key records are not deleted. I tried begin; create temp table t1 ( pk integer primary key ); insert into t1 values(1);