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
<font
size=2 color=blue face="Courier New"><span style='font-size:10.0pt;font-family:
"Courier New";color:blue'>I can see the confusion here.<span
style="mso-spacerun: yes"> The point is not to let someone enter
data<span
style='font-size:10.0pt;font-family:"Courier New";color:blue;mso-color-alt:
windowtext'>
<font
size=2 color=blue face="Courier New"><span style='font-size:10.0pt;font-family:
"Courier New";color:blue'>that would violate the referential integrity.<span
style="mso-spacerun: yes"> Let me explain with an<font
size=2 color=blue face="Courier New"><span style='font-size:10.0pt;font-family:
"Courier New";color:blue;mso-color-alt:windowtext'>
<font
size=2 color=blue face="Courier New"><span style='font-size:10.0pt;font-family:
"Courier New";color:blue'>example:<font size=2 color=blue
face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New";
color:blue;mso-color-alt:windowtext'>
<font
size=2 color=blue face="Courier New"><span style='font-size:10.0pt;font-family:
"Courier New";color:blue'> <font
size=2 color=blue face="Courier New"><span style='font-size:10.0pt;font-family:
"Courier New";color:blue;mso-color-alt:windowtext'>
<p class=MsoNormal style='margin-left:42.0pt;text-indent:-24.0pt;mso-list:l0 level1 lfo3;
tab-stops:list 42.0pt;mso-layout-grid-align:none;text-autospace:none'><font
size=2 color=blue face="Courier New"><span style='font-size:10.0pt;font-family:
"Courier New";color:blue;mso-color-alt:windowtext'>1.<font size=1
face="Times New Roman">
<span
style='font-size:10.0pt;font-family:"Courier New";color:blue'>User wants to
update a primary key record in parent table<font size=2
color=blue face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New";
color:blue;mso-color-alt:windowtext'>
<p class=MsoNormal style='margin-left:42.0pt;text-indent:-24.0pt;mso-list:l0 level1 lfo3;
tab-stops:list 42.0pt;mso-layout-grid-align:none;text-autospace:none'><font
size=2 color=blue face="Courier New"><span style='font-size:10.0pt;font-family:
"Courier New";color:blue;mso-color-alt:windowtext'>2.<font size=1
face="Times New Roman">
<span
style='font-size:10.0pt;font-family:"Courier New";color:blue'>Dependent data
exists in a child table so the user gets an error while trying to perform step
1<span
style='font-size:10.0pt;font-family:"Courier New";color:blue;mso-color-alt:
windowtext'>
<p class=MsoNormal style='margin-left:42.0pt;text-indent:-24.0pt;mso-list:l0 level1 lfo3;
tab-stops:list 42.0pt;mso-layout-grid-align:none;text-autospace:none'><font
size=2 color=blue face="Courier New"><span style='font-size:10.0pt;font-family:
"Courier New";color:blue;mso-color-alt:windowtext'>3.<font size=1
face="Times New Roman">
<span
style='font-size:10.0pt;font-family:"Courier New";color:blue'>It is necessary
to disable the FK constraint in order to update both tables<font
size=2 color=blue face="Courier New"><span style='font-size:10.0pt;font-family:
"Courier New";color:blue;mso-color-alt:windowtext'>
<p class=MsoNormal style='margin-left:42.0pt;text-indent:-24.0pt;mso-list:l0 level1 lfo3;
tab-stops:list 42.0pt;mso-layout-grid-align:none;text-autospace:none'><font
size=2 color=blue face="Courier New"><span style='font-size:10.0pt;font-family:
"Courier New";color:blue;mso-color-alt:windowtext'>4.<font size=1
face="Times New Roman">
<span
style='font-size:10.0pt;font-family:"Courier New";color:blue'>Enable the FK
constraint successfully<span
style='font-size:10.0pt;font-family:"Courier New";color:blue;mso-color-alt:
windowtext'>
<font
size=2 color=blue face="Courier New"><span style='font-size:10.0pt;font-family:
"Courier New";color:blue'> <font
size=2 color=blue face="Courier New"><span style='font-size:10.0pt;font-family:
"Courier New";color:blue;mso-color-alt:windowtext'>
<font
size=2 color=blue face="Courier New"><span style='font-size:10.0pt;font-family:
"Courier New";color:blue'> <font
size=2 color=blue face="Courier New"><span style='font-size:10.0pt;font-family:
"Courier New";color:blue;mso-color-alt:windowtext'>
<font
size=2 color=blue face="Courier New"><span style='font-size:10.0pt;font-family:
"Courier New";color:blue'>Does that make sense?<span style="mso-spacerun:
yes"> This is a process we have to do routinely and it has<font
size=2 color=blue face="Courier New"><span style='font-size:10.0pt;font-family:
"Courier New";color:blue;mso-color-alt:windowtext'>
<font
size=2 color=blue face="Courier New"><span style='font-size:10.0pt;font-family:
"Courier New";color:blue'>happened in the past that the FK was mistakenly not
re-enabled, which<span
style='font-size:10.0pt;font-family:"Courier New";color:blue;mso-color-alt:
windowtext'>
<font
size=2 color=blue face="Courier New"><span style='font-size:10.0pt;font-family:
"Courier New";color:blue'>allowed "illegal" data to be loaded later.<span
style="mso-spacerun: yes"> Thus the need for a script.<font
size=2 color=blue face="Courier New"><span style='font-size:10.0pt;font-family:
"Courier New";color:blue;mso-color-alt:windowtext'>
<span
style='font-size:10.0pt;mso-bidi-font-size:12.0pt;font-family:Arial'>
<span
style='font-size:10.0pt;mso-bidi-font-size:12.0pt;font-family:Arial'>
<!---size:10.0pt;mso-bidi-font-size:
12.0pt;font-family:Arial'><span
style="mso-spacerun: yes"> AUTOTEXTLIST \s "E-mail
Signature" <font
size=2 color=blue face=Arial><span style='font-size:10.0pt;mso-bidi-font-size:
12.0pt;font-family:Arial;color:blue;font-weight:bold'>David B. Wagoner
<span
style='font-size:10.0pt;mso-bidi-font-size:12.0pt;font-family:Arial;color:blue;
font-style:italic'>Database Administrator<font size=2
color=blue face=Arial><span style='font-size:10.0pt;mso-bidi-font-size:12.0pt;
font-family:Arial;color:blue;mso-color-alt:windowtext;font-style:italic'>
<span
style='font-size:10.0pt;mso-bidi-font-size:12.0pt;font-family:Arial;color:blue;
font-weight:bold'>Arsenal Digital Solutions Worldwide Inc.<font
size=2 color=blue face=Arial><span style='font-size:10.0pt;mso-bidi-font-size:
12.0pt;font-family:Arial;color:blue;mso-color-alt:windowtext;font-weight:bold'>
<span style='font-size:
10.0pt;mso-bidi-font-size:12.0pt;font-family:Arial;color:blue'>4815 Emperor
Blvd., Suite 110<span
style='font-size:10.0pt;mso-bidi-font-size:12.0pt;font-family:Arial;color:blue;
mso-color-alt:windowtext'>
<span style='font-size:
10.0pt;mso-bidi-font-size:12.0pt;font-family:Arial;color:blue'>Durham, NC 27703<font
size=2 color=blue face=Arial><span style='font-size:10.0pt;mso-bidi-font-size:
12.0pt;font-family:Arial;color:blue;mso-color-alt:windowtext'>
<span style='font-size:
10.0pt;mso-bidi-font-size:12.0pt;font-family:Arial;color:blue'>Tel. (919)
941-4645<span
style='font-size:10.0pt;mso-bidi-font-size:12.0pt;font-family:Arial;color:blue;
mso-color-alt:windowtext'>
<span style='font-size:
10.0pt;mso-bidi-font-size:12.0pt;font-family:Arial;color:blue'>Fax (919)
474-0735<span
style='font-size:10.0pt;mso-bidi-font-size:12.0pt;font-family:Arial;color:blue;
mso-color-alt:windowtext'>
<span style='font-size:
10.0pt;mso-bidi-font-size:12.0pt;font-family:Arial;color:blue'>Email <a
href="mailto:dwagoner_at_arsenaldigital.com"><span
style='font-family:"Times New Roman"'>mailto:dwagoner_at_arsenaldigital.com<font
size=2 color=blue face=Arial><span style='font-size:10.0pt;mso-bidi-font-size:
12.0pt;font-family:Arial;color:blue;mso-color-alt:windowtext'>
<span style='font-size:
10.0pt;mso-bidi-font-size:12.0pt;font-family:Arial;color:blue'>Web <a
href="http://www.arsenaldigital.com/"><span
style='font-family:"Times New Roman"'>http://www.arsenaldigital.com/<font
size=2 color=blue face=Arial><span style='font-size:10.0pt;mso-bidi-font-size:
12.0pt;font-family:Arial;color:blue;mso-color-alt:windowtext'>
<span style='font-size:
10.0pt;mso-bidi-font-size:12.0pt;font-family:Arial;color:blue'> <font
size=2 color=blue face=Arial><span style='font-size:10.0pt;mso-bidi-font-size:
12.0pt;font-family:Arial;color:blue;mso-color-alt:windowtext'>
<span style='font-size:
10.0pt;mso-bidi-font-size:12.0pt;font-family:Arial;color:blue'><span
style="mso-spacerun:
yes">
<span style='font-size:
8.0pt;mso-bidi-font-size:12.0pt;font-family:Arial;color:blue'>This e-mail
message is confidential, intended only for the named recipient(s) above and may
contain information that is privileged, work product or exempt from disclosure
under applicable law. If you have
received this message in error, or are not the named recipient(s), please
immediately notify the sender at (919) 941-4645 and delete this e-mail message
from your computer. Thank you.<font
size=1 color=blue face=Arial><span style='font-size:8.0pt;mso-bidi-font-size:
12.0pt;font-family:Arial;color:blue;mso-color-alt:windowtext'>
<!---size:10.0pt;mso-bidi-font-size:
12.0pt;font-family:Arial'><span
class=EmailStyle20><span style='font-size:
10.0pt;mso-bidi-font-size:12.0pt;font-family:Arial'>
<font size=2 color=black
face=Tahoma>-----Original
Message-----
From: Mark Leith
[mailto:mark_at_cool-tools.co.uk]
Sent: Wednesday, November 28, 2001
5:20 AM
To: Multiple recipients of list
ORACLE-L
Subject: RE: Script to Disable
Constraint, Change Value, then Enable Constrain
<span
style='font-size:12.0pt'>
<span
style='font-size:10.0pt;font-family:Arial;color:blue'>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?<font
color=black>
<font size=3 color=black
face="Times New Roman"> <font
color=black>
<span
style='font-size:10.0pt;font-family:Arial;color:blue'>Not a good approach.. How
can you ensure that the user hasn't put a duplicate value in (unique
constraint) or something else that might break the constraint rule? The only
way you are going to know is when you try and re-enable the constraint it will
fail.. <span style='color:black;mso-color-alt:
windowtext'>
<font size=3 color=black
face="Times New Roman"> <font
color=black>
<span
style='font-size:10.0pt;font-family:Arial;color:blue'>I struggle to see why you
would want to do this - do you have any more info?<font
color=black>
<p class=MsoNormal style='mso-margin-top-alt:auto;margin-bottom:12.0pt;
margin-left:1.0in'><span style='font-size:
10.0pt;font-family:Tahoma;color:black'>-----Original Message-----
From: root_at_fatcity.com
[mailto:root_at_fatcity.com]On Behalf Of David
Wagoner
Sent: 27 November 2001 21:30
To: Multiple recipients of list
ORACLE-L
Subject: Script to Disable
Constraint, Change Value, then Enable Constrain<span
style='color:black;mso-color-alt:windowtext'>
<font
size=2 color=black face=Arial><span style='font-size:10.0pt;mso-bidi-font-size:
12.0pt;font-family:Arial'>Listers,
<font
size=2 color=black face=Arial><span style='font-size:10.0pt;mso-bidi-font-size:
12.0pt;font-family:Arial'>
<font
size=2 color=black face=Arial><span style='font-size:10.0pt;mso-bidi-font-size:
12.0pt;font-family:Arial'>Does anyone have a script that will do the following:
<font
size=2 color=black face=Arial><span style='font-size:10.0pt;mso-bidi-font-size:
12.0pt;font-family:Arial'>
<p class=MsoNormal style='margin-left:1.5in;text-indent:-.25in;mso-list:l1 level1 lfo1;
tab-stops:list 1.0in'><font
size=2 color=black face=Arial><span style='font-size:10.0pt;mso-bidi-font-size:
12.0pt;font-family:Arial'>1.<span
style='font:7.0pt "Times New Roman"'> <span
class=EmailStyle19><span style='font-size:
10.0pt;mso-bidi-font-size:12.0pt;font-family:Arial'>Accept user input for old
data value <span
class=EmailStyle19><span style='font-size:
10.0pt;mso-bidi-font-size:12.0pt;font-family:Arial'>
<p class=MsoNormal style='margin-left:1.5in;text-indent:-.25in;mso-list:l1 level1 lfo1;
tab-stops:list 1.0in'><font
size=2 color=black face=Arial><span style='font-size:10.0pt;mso-bidi-font-size:
12.0pt;font-family:Arial'>2.<span
style='font:7.0pt "Times New Roman"'> <span
class=EmailStyle19><span style='font-size:
10.0pt;mso-bidi-font-size:12.0pt;font-family:Arial'>Accept user input for new
data value <span
class=EmailStyle19><span style='font-size:
10.0pt;mso-bidi-font-size:12.0pt;font-family:Arial'>
<p class=MsoNormal style='margin-left:1.5in;text-indent:-.25in;mso-list:l1 level1 lfo1;
tab-stops:list 1.0in'><font
size=2 color=black face=Arial><span style='font-size:10.0pt;mso-bidi-font-size:
12.0pt;font-family:Arial'>3.<span
style='font:7.0pt "Times New Roman"'> <span
class=EmailStyle19><span style='font-size:
10.0pt;mso-bidi-font-size:12.0pt;font-family:Arial'>Disable table constraint<font
color=black> <font
size=2 color=black face=Arial><span style='font-size:10.0pt;mso-bidi-font-size:
12.0pt;font-family:Arial'>
<p class=MsoNormal style='margin-left:1.5in;text-indent:-.25in;mso-list:l1 level1 lfo1;
tab-stops:list 1.0in'><font
size=2 color=black face=Arial><span style='font-size:10.0pt;mso-bidi-font-size:
12.0pt;font-family:Arial'>4.<span
style='font:7.0pt "Times New Roman"'> <span
class=EmailStyle19><span style='font-size:
10.0pt;mso-bidi-font-size:12.0pt;font-family:Arial'>Update record with new data
value <span
class=EmailStyle19><span style='font-size:
10.0pt;mso-bidi-font-size:12.0pt;font-family:Arial'>
<p class=MsoNormal style='margin-left:1.5in;text-indent:-.25in;mso-list:l1 level1 lfo1;
tab-stops:list 1.0in'><font
size=2 color=black face=Arial><span style='font-size:10.0pt;mso-bidi-font-size:
12.0pt;font-family:Arial'>5.<span
style='font:7.0pt "Times New Roman"'> <span
class=EmailStyle19><span style='font-size:
10.0pt;mso-bidi-font-size:12.0pt;font-family:Arial'>Enable constraint<font
color=black> <font
size=2 color=black face=Arial><span style='font-size:10.0pt;mso-bidi-font-size:
12.0pt;font-family:Arial'>
<font
size=2 color=black face=Arial><span style='font-size:10.0pt;mso-bidi-font-size:
12.0pt;font-family:Arial'>
<font
size=2 color=black face=Arial><span style='font-size:10.0pt;mso-bidi-font-size:
12.0pt;font-family:Arial'>A script like this would help ensure that constraints
are not left "off" after updates, allowing "illegal" data
into the tables. Good user-proof
script I would think.
<font
size=2 color=black face=Arial><span style='font-size:10.0pt;mso-bidi-font-size:
12.0pt;font-family:Arial'>
<font
size=2 color=black face=Arial><span style='font-size:10.0pt;mso-bidi-font-size:
12.0pt;font-family:Arial'>
<font
size=2 color=black face=Arial><span style='font-size:10.0pt;mso-bidi-font-size:
12.0pt;font-family:Arial'>TIA,
<font
size=2 color=black face=Arial><span style='font-size:10.0pt;mso-bidi-font-size:
12.0pt;font-family:Arial'>
<font
size=2 color=black face=Arial><span style='font-size:10.0pt;mso-bidi-font-size:
12.0pt;font-family:Arial'>david
<font
size=2 color=black face=Arial><span style='font-size:10.0pt;mso-bidi-font-size:
12.0pt;font-family:Arial'>
<span
style="mso-spacerun: yes"> AUTOTEXTLIST \s "E-mail
Signature" <font
size=2 color=blue face=Arial><span style='font-size:10.0pt;mso-bidi-font-size:
12.0pt;font-family:Arial;color:blue;font-weight:bold'>David B. Wagoner
<font size=2 color=black
face=Arial><span style='font-size:10.0pt;mso-bidi-font-size:12.0pt;font-family:
Arial;color:black;font-style:italic'>Database Administrator<font
size=2 color=black face=Arial><span style='font-size:10.0pt;mso-bidi-font-size:
12.0pt;font-family:Arial;color:black;mso-color-alt:windowtext;font-style:italic'>
<font size=2 color=black
face=Arial><span style='font-size:10.0pt;mso-bidi-font-size:12.0pt;font-family:
Arial;color:black;font-weight:bold'>Arsenal Digital Solutions Worldwide Inc.<font
size=2 color=black face=Arial><span style='font-size:10.0pt;mso-bidi-font-size:
12.0pt;font-family:Arial;color:black;mso-color-alt:windowtext;font-weight:bold'>
<font size=2 color=black
face=Arial><span style='font-size:10.0pt;mso-bidi-font-size:12.0pt;font-family:
Arial;color:black'>4815 Emperor Blvd., Suite 110<font size=2
color=black face=Arial><span style='font-size:10.0pt;mso-bidi-font-size:12.0pt;
font-family:Arial;color:black;mso-color-alt:windowtext'>
<font size=2 color=black
face=Arial><span style='font-size:10.0pt;mso-bidi-font-size:12.0pt;font-family:
Arial;color:black'>Durham, NC 27703<font size=2 color=black
face=Arial><span style='font-size:10.0pt;mso-bidi-font-size:12.0pt;font-family:
Arial;color:black;mso-color-alt:windowtext'>
<font size=2 color=black
face=Arial><span style='font-size:10.0pt;mso-bidi-font-size:12.0pt;font-family:
Arial;color:black'>Tel. (919) 941-4645<font size=2 color=black
face=Arial><span style='font-size:10.0pt;mso-bidi-font-size:12.0pt;font-family:
Arial;color:black;mso-color-alt:windowtext'>
<font size=2 color=black
face=Arial><span style='font-size:10.0pt;mso-bidi-font-size:12.0pt;font-family:
Arial;color:black'>Fax (919) 474-0735<font size=2 color=black
face=Arial><span style='font-size:10.0pt;mso-bidi-font-size:12.0pt;font-family:
Arial;color:black;mso-color-alt:windowtext'>
<font size=2 color=black
face=Arial><span style='font-size:10.0pt;mso-bidi-font-size:12.0pt;font-family:
Arial;color:black'>Email <font
face="Times New Roman">mailto:dwagoner_at_arsenaldigital.com<font
size=2 color=black face=Arial><span style='font-size:10.0pt;mso-bidi-font-size:
12.0pt;font-family:Arial;color:black;mso-color-alt:windowtext'>
<font size=2 color=black
face=Arial><span style='font-size:10.0pt;mso-bidi-font-size:12.0pt;font-family:
Arial;color:black'>Web <font
face="Times New Roman">http://www.arsenaldigital.com/<font
size=2 color=black face=Arial><span style='font-size:10.0pt;mso-bidi-font-size:
12.0pt;font-family:Arial;color:black;mso-color-alt:windowtext'>
<font size=2 color=black
face=Arial><span style='font-size:10.0pt;mso-bidi-font-size:12.0pt;font-family:
Arial;color:black'> <span
style='font-size:10.0pt;mso-bidi-font-size:12.0pt;font-family:Arial;color:black;
mso-color-alt:windowtext'>
<font size=2 color=black
face=Arial><span style='font-size:10.0pt;mso-bidi-font-size:12.0pt;font-family:
Arial;color:black'><span style="mso-spacerun:
yes">
yes"> <font
<font size=1 color=black
face=Arial><span style='font-size:8.0pt;mso-bidi-font-size:12.0pt;font-family:
Arial;color:black'>This e-mail message is confidential, intended only for the
named recipient(s) above and may contain information that is privileged, work
product or exempt from disclosure under applicable law.<span
style="mso-spacerun: yes"> If you have received this message in
error, or are not the named recipient(s), please immediately notify the sender
at (919) 941-4645 and delete this e-mail message from your computer.<span
style="mso-spacerun: yes"> Thank you.<font size=1
color=black face=Arial><span style='font-size:8.0pt;mso-bidi-font-size:12.0pt;
font-family:Arial;color:black;mso-color-alt:windowtext'>
<font
color=black> <span
style='color:black;mso-color-alt:windowtext'>
Received on Wed Nov 28 2001 - 10:55:02 CST
![]() |
![]() |