Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Mailing Lists -> Oracle-L -> RE: Script to Disable Constraint, Change Value, then Enable Const
I have
had the same type of requirement and decided to use deferrable constraints.
Works
great!
<FONT face=Arial color=#0000ff
size=2>
<FONT face=Arial color=#0000ff
size=2>Rick
<FONT face=Tahoma
size=2>-----Original Message-----From: Igor Neyman
[mailto:ineyman_at_perceptron.com]Sent: Wednesday, November 28, 2001
11:56 AMTo: Multiple recipients of list ORACLE-LSubject:
Re: Script to Disable Constraint, Change Value, then Enable
Const
Not good approach.
Instead, use 'deferrable constraints, should work in your
situation.
Igor Neyman, OCP DBA<A
href="mailto:ineyman_at_perceptron.com">ineyman_at_perceptron.com
<BLOCKQUOTE dir=ltr
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
Sent: Wednesday, November 28, 2001
11:24 AM
Subject: RE: Script to Disable
Constraint, Change Value, then Enable Const
<FONT
face="Courier New" color=blue size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'">I can see
the confusion here. The point
is not to let someone enter data<FONT face="Courier New"
color=blue size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-color-alt: windowtext">
<FONT
face="Courier New" color=blue size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'">that would
violate the referential integrity.
Let me explain with an<FONT face="Courier New"
color=blue size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-color-alt: windowtext">
<FONT
face="Courier New" color=blue size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'">example:<FONT
face="Courier New" color=blue size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-color-alt: windowtext">
<FONT
face="Courier New" color=blue size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'"><SPAN
style="mso-spacerun: yes"> <FONT
face="Courier New" color=blue size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-color-alt: windowtext">
<P class=MsoNormal
style="MARGIN-LEFT: 42pt; TEXT-INDENT: -24pt; mso-layout-grid-align: none; mso-list: l0 level1 lfo3; tab-stops: list 42.0pt"><FONT
face="Courier New" color=blue size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-color-alt: windowtext">1.<FONT
face="Times New Roman" size=1><SPAN
style="FONT: 7pt 'Times New Roman'">
<FONT face="Courier New" color=blue
size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'">User wants
to update a primary key record in parent table<FONT
face="Courier New" color=blue size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-color-alt: windowtext">
<P class=MsoNormal
style="MARGIN-LEFT: 42pt; TEXT-INDENT: -24pt; mso-layout-grid-align: none; mso-list: l0 level1 lfo3; tab-stops: list 42.0pt"><FONT
face="Courier New" color=blue size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-color-alt: windowtext">2.<FONT
face="Times New Roman" size=1><SPAN
style="FONT: 7pt 'Times New Roman'">
<FONT face="Courier New" color=blue
size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'">Dependent
data exists in a child table so the user gets an error while trying to
perform step 1<SPAN
style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-color-alt: windowtext">
<P class=MsoNormal
style="MARGIN-LEFT: 42pt; TEXT-INDENT: -24pt; mso-layout-grid-align: none; mso-list: l0 level1 lfo3; tab-stops: list 42.0pt"><FONT
face="Courier New" color=blue size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-color-alt: windowtext">3.<FONT
face="Times New Roman" size=1><SPAN
style="FONT: 7pt 'Times New Roman'">
<FONT face="Courier New" color=blue
size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'">It is
necessary to disable the FK constraint in order to update both
tables<SPAN
style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-color-alt: windowtext">
<P class=MsoNormal
style="MARGIN-LEFT: 42pt; TEXT-INDENT: -24pt; mso-layout-grid-align: none; mso-list: l0 level1 lfo3; tab-stops: list 42.0pt"><FONT
face="Courier New" color=blue size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-color-alt: windowtext">4.<FONT
face="Times New Roman" size=1><SPAN
style="FONT: 7pt 'Times New Roman'">
<FONT face="Courier New" color=blue
size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'">Enable the
FK constraint successfully<FONT face="Courier New" color=blue
size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-color-alt: windowtext">
<FONT
face="Courier New" color=blue size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'"><SPAN
style="mso-spacerun: yes"> <FONT
face="Courier New" color=blue size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-color-alt: windowtext">
<FONT
face="Courier New" color=blue size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'"><SPAN
style="mso-spacerun: yes"> <FONT
face="Courier New" color=blue size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-color-alt: windowtext">
<FONT
face="Courier New" color=blue size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'">Does that
make sense? This is a process
we have to do routinely and it has<FONT face="Courier New"
color=blue size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-color-alt: windowtext">
<FONT
face="Courier New" color=blue size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'">happened in
the past that the FK was mistakenly not re-enabled, which<FONT
face="Courier New" color=blue size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-color-alt: windowtext">
<FONT
face="Courier New" color=blue size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'">allowed
"illegal" data to be loaded later.
Thus the need for a script.<FONT face="Courier New"
color=blue size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-color-alt: windowtext">
<FONT face=Arial color=blue
size=2><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: Arial; mso-bidi-font-size: 12.0pt">
<FONT face=Arial color=blue
size=2><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: Arial; mso-bidi-font-size: 12.0pt">
<!---size:10.0pt;mso-bidi-font-size:
12.0pt;font-family:Arial'><span
style="mso-spacerun: yes"> AUTOTEXTLIST \s "E-mail
Signature" <FONT
face=Arial color=blue size=2><SPAN
style="FONT-WEIGHT: bold; FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Arial; mso-bidi-font-size: 12.0pt">David
B. Wagoner
<SPAN
style="FONT-SIZE: 10pt; COLOR: blue; FONT-STYLE: italic; FONT-FAMILY: Arial; mso-bidi-font-size: 12.0pt">Database
Administrator<SPAN
style="FONT-SIZE: 10pt; COLOR: blue; FONT-STYLE: italic; FONT-FAMILY: Arial; mso-color-alt: windowtext; mso-bidi-font-size: 12.0pt">
<SPAN
style="FONT-WEIGHT: bold; FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Arial; mso-bidi-font-size: 12.0pt">Arsenal
Digital Solutions Worldwide Inc.<FONT face=Arial
color=blue size=2><SPAN
style="FONT-WEIGHT: bold; FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Arial; mso-color-alt: windowtext; mso-bidi-font-size: 12.0pt">
<SPAN
style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Arial; mso-bidi-font-size: 12.0pt">4815
Emperor Blvd., Suite 110<FONT face=Arial color=blue
size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Arial; mso-color-alt: windowtext; mso-bidi-font-size: 12.0pt">
<SPAN
style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Arial; mso-bidi-font-size: 12.0pt">Durham,
NC 27703<SPAN
style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Arial; mso-color-alt: windowtext; mso-bidi-font-size: 12.0pt">
<SPAN
style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Arial; mso-bidi-font-size: 12.0pt">Tel.
(919) 941-4645<SPAN
style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Arial; mso-color-alt: windowtext; mso-bidi-font-size: 12.0pt">
<SPAN
style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Arial; mso-bidi-font-size: 12.0pt">Fax
(919) 474-0735<SPAN
style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Arial; mso-color-alt: windowtext; mso-bidi-font-size: 12.0pt">
<SPAN
style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Arial; mso-bidi-font-size: 12.0pt">Email
<FONT
face="Times New Roman"><SPAN
style="FONT-FAMILY: 'Times New Roman'">mailto:dwagoner_at_arsenaldigital.com<FONT
face=Arial color=blue size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Arial; mso-color-alt: windowtext; mso-bidi-font-size: 12.0pt">
<SPAN
style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Arial; mso-bidi-font-size: 12.0pt">Web
<SPAN
style="FONT-FAMILY: 'Times New Roman'">http://www.arsenaldigital.com/<FONT
face=Arial color=blue size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Arial; mso-color-alt: windowtext; mso-bidi-font-size: 12.0pt">
<SPAN
style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Arial; mso-bidi-font-size: 12.0pt"> <FONT
face=Arial color=blue size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Arial; mso-color-alt: windowtext; mso-bidi-font-size: 12.0pt">
<SPAN
style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Arial; mso-bidi-font-size: 12.0pt"><SPAN
style="mso-spacerun: yes">
style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: Arial; mso-bidi-font-size: 12.0pt">***<SPAN style="mso-spacerun: yes"> NOTICE<SPAN style="mso-spacerun: yes"> ***<FONT face=Arial color=blue size=1><SPAN style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: Arial; mso-color-alt: windowtext; mso-bidi-font-size: 12.0pt">
class=EmailStyle20><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: Arial; mso-bidi-font-size: 12.0pt">
<FONT face=Tahoma color=black
size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Tahoma">-----Original
Message-----From: Mark
Leith [mailto:mark_at_cool-tools.co.uk]<SPAN
style="FONT-WEIGHT: bold">Sent: Wednesday, November 28, 2001 5:20
AMTo: Multiple recipients
of list ORACLE-LSubject:
RE: Script to Disable Constraint, Change Value, then Enable
Constrain
<FONT face="Times New Roman"
size=3><SPAN
style="FONT-SIZE: 12pt">
<FONT face=Arial color=blue
size=2>How
could this be user proof? You are essentially disabling the constraint that
WILL enforce data integrity, then letting the user input whatever rubbish he
wants to, and are then going to try and enable the constraint
afterwards?<SPAN
style="COLOR: black; mso-color-alt: windowtext">
<FONT face="Times New Roman"
color=black size=3><SPAN style="FONT-SIZE: 12pt; COLOR: black"> <FONT color=black><SPAN style="COLOR: black; mso-color-alt: windowtext">
color=black size=3><SPAN style="FONT-SIZE: 12pt; COLOR: black"> <FONT color=black><SPAN style="COLOR: black; mso-color-alt: windowtext">
style="MARGIN-LEFT: 1.5in; TEXT-INDENT: -0.25in; mso-list: l1 level1 lfo1; tab-stops: list 1.0in"><SPAN class=EmailStyle19><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial; mso-bidi-font-size: 12.0pt">1.<FONTface="Times New Roman" size=1><SPAN style="FONT: 7pt 'Times New Roman'">
style="MARGIN-LEFT: 1.5in; TEXT-INDENT: -0.25in; mso-list: l1 level1 lfo1; tab-stops: list 1.0in"><SPAN class=EmailStyle19><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial; mso-bidi-font-size: 12.0pt">2.<FONTface="Times New Roman" size=1><SPAN style="FONT: 7pt 'Times New Roman'">
style="MARGIN-LEFT: 1.5in; TEXT-INDENT: -0.25in; mso-list: l1 level1 lfo1; tab-stops: list 1.0in"><SPAN class=EmailStyle19><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial; mso-bidi-font-size: 12.0pt">3.<FONTface="Times New Roman" size=1><SPAN style="FONT: 7pt 'Times New Roman'">
style="MARGIN-LEFT: 1.5in; TEXT-INDENT: -0.25in; mso-list: l1 level1 lfo1; tab-stops: list 1.0in"><SPAN class=EmailStyle19><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial; mso-bidi-font-size: 12.0pt">4.<FONTface="Times New Roman" size=1><SPAN style="FONT: 7pt 'Times New Roman'">
style="MARGIN-LEFT: 1.5in; TEXT-INDENT: -0.25in; mso-list: l1 level1 lfo1; tab-stops: list 1.0in"><SPAN class=EmailStyle19><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial; mso-bidi-font-size: 12.0pt">5.<FONTface="Times New Roman" size=1><SPAN style="FONT: 7pt 'Times New Roman'">
face=Arial color=blue size=2><SPAN
style="FONT-WEIGHT: bold; FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Arial; mso-bidi-font-size: 12.0pt">David
B. Wagoner
<FONT face=Arial color=black
size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: black; FONT-STYLE: italic; FONT-FAMILY: Arial; mso-bidi-font-size: 12.0pt">Database
Administrator<SPAN
style="FONT-SIZE: 10pt; COLOR: black; FONT-STYLE: italic; FONT-FAMILY: Arial; mso-color-alt: windowtext; mso-bidi-font-size: 12.0pt">
<FONT face=Arial color=black
size=2><SPAN
style="FONT-WEIGHT: bold; FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Arial; mso-bidi-font-size: 12.0pt">Arsenal
Digital Solutions Worldwide Inc.<FONT face=Arial
color=black size=2><SPAN
style="FONT-WEIGHT: bold; FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Arial; mso-color-alt: windowtext; mso-bidi-font-size: 12.0pt">
<FONT face=Arial color=black
size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Arial; mso-bidi-font-size: 12.0pt">4815
Emperor Blvd., Suite 110<FONT face=Arial color=black
size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Arial; mso-color-alt: windowtext; mso-bidi-font-size: 12.0pt">
<FONT face=Arial color=black
size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Arial; mso-bidi-font-size: 12.0pt">Durham,
NC 27703<SPAN
style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Arial; mso-color-alt: windowtext; mso-bidi-font-size: 12.0pt">
<FONT face=Arial color=black
size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Arial; mso-bidi-font-size: 12.0pt">Tel.
(919) 941-4645<SPAN
style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Arial; mso-color-alt: windowtext; mso-bidi-font-size: 12.0pt">
<FONT face=Arial color=black
size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Arial; mso-bidi-font-size: 12.0pt">Fax
(919) 474-0735<SPAN
style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Arial; mso-color-alt: windowtext; mso-bidi-font-size: 12.0pt">
<FONT face=Arial color=black
size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Arial; mso-bidi-font-size: 12.0pt">Email
<FONT
face="Times New Roman"><SPAN
style="FONT-FAMILY: 'Times New Roman'">mailto:dwagoner_at_arsenaldigital.com<FONT
face=Arial color=black size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Arial; mso-color-alt: windowtext; mso-bidi-font-size: 12.0pt">
<FONT face=Arial color=black
size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Arial; mso-bidi-font-size: 12.0pt">Web
<SPAN
style="FONT-FAMILY: 'Times New Roman'">http://www.arsenaldigital.com/<FONT
face=Arial color=black size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Arial; mso-color-alt: windowtext; mso-bidi-font-size: 12.0pt">
<FONT face=Arial color=black
size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Arial; mso-bidi-font-size: 12.0pt"> <FONT
face=Arial color=black size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Arial; mso-color-alt: windowtext; mso-bidi-font-size: 12.0pt">
<FONT face=Arial color=black
size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Arial; mso-bidi-font-size: 12.0pt"><SPAN
style="mso-spacerun: yes">
style="mso-spacerun: yes"> <FONTface=Arial color=black size=1><SPAN
style="FONT-SIZE: 8pt; COLOR: black; FONT-FAMILY: Arial; mso-bidi-font-size: 12.0pt">***<SPAN style="mso-spacerun: yes"> NOTICE<SPAN style="mso-spacerun: yes"> ***<FONT face=Arial color=black size=1><SPAN style="FONT-SIZE: 8pt; COLOR: black; FONT-FAMILY: Arial; mso-color-alt: windowtext; mso-bidi-font-size: 12.0pt">
color=black> <FONT color=black><SPAN style="COLOR: black; mso-color-alt: windowtext">Received on Wed Nov 28 2001 - 11:46:43 CST
![]() |
![]() |