Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Re: change foreign key value????
the solutions I've seen don't seem safe. Is it legal to change an invoice number anyway?
What if someone else adds a master invoice with the number you want to use before you change your master?
Safer to insert a new master first then change the detail then delete the original master.
jm2c
Stephan Langer wrote:
>
> hi,
>
> try
> alter table <table_name> disable constraint <contraint_name>;
> and
> alter table <table_name> enable constraint <contraint_name>;
>
> this will diable the constraint for all users (not just the actual
> transaction) temporarily. And you can't enable the constraint again if in
> the meantime someone has inserts an row that doesn't fit to the constraint.
>
> hth
> SL
>
> andy schrieb:
>
> > I have two tables: MASTER and DETAIL.
> >
> > Master.INV_NO is the primary key
> >
> > Detail has a fk constraint on INV_NO.
> >
> > I want to create a utility to change an invoice number.
> >
> > If I write
> >
> > begin
> > Update Master set INV_NO = 2 where INV_NO = 1;
> > Update Detail set INV_NO = 2 where INV_NO = 1;
> > Commit;
> > end;
> >
> > it fails because the constraint is violated temporarily.
> >
> > Is there anyway to easily temporarily disable the FK constraint during a
> > transaction. (i.e. disable until commit is called)??
> >
> > thanks,
> >
> > andy
Received on Thu Oct 19 2000 - 09:25:05 CDT
![]() |
![]() |