Firebird SQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesFirebird SQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old December 13th, 2006, 04:38 AM
Bidibulle Bidibulle is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2006
Posts: 3 Bidibulle User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 23 m
Reputation Power: 0
Remove NOT NULL on a column

Hi All !

I have a problem.
First of all, I have a table called TOCCUPATION
In this table, I've got a field called STRUCTUREPARETAPE
This field is NOT NULL (and it is a foreign key that references the table called TSTRUCTUREPARETAPE)

Now I change this field and I remove the NOT NULL by doing this :
update RDB$RELATION_FIELDS set
RDB$NULL_FLAG = NULL
where (RDB$FIELD_NAME = 'STRUCTUREPARETAPE') and
(RDB$RELATION_NAME = 'TPOSTEPARETAPE')

Unfortunately, I can't do an insert with a null value for this field.

I tried to create a new domain for the STRUCTUREPARETAPE field but it doesn't work.

Some idea ?

Thank you !

Reply With Quote
  #2  
Old December 13th, 2006, 09:04 AM
pabloj's Avatar
pabloj pabloj is offline
Modding: Oracle MsSQL Firebird
Dev Shed God 6th Plane (7500 - 7999 posts)
 
Join Date: Jun 2001
Location: Outside US
Posts: 7,815 pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level) 
Time spent in forums: 2 Months 3 Weeks 1 Day 14 m 37 sec
Reputation Power: 278
Direct modifications of metadata tables are one of the best ways to get into trouble

Reply With Quote
  #3  
Old December 13th, 2006, 03:30 PM
Bidibulle Bidibulle is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2006
Posts: 3 Bidibulle User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 23 m
Reputation Power: 0
Sure but I need this modification.
This is the way I proceed and it's not secure at all because you have to know what you do but everything seems alright.

I dropped every constraints and procedures
I copied the data of the column in a temporary table
I dropped the column
I recreate the column without the not null constraint
I copied data from the temp table to the official table
I recreate every constraint and procedures

It is 'du bidouillage' as we say here, in belgium but that was the only way I find.
Hope to avoid troubles

Reply With Quote
  #4  
Old December 15th, 2006, 04:30 PM
shammat shammat is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Oct 2003
Location: Munich, Bavaria
Posts: 989 shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level)shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level)shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level)shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level)shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level)shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level)shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Week 3 Days 2 h 3 m 55 sec
Reputation Power: 57
You can drop the constraint that is connected to the NOT NULL definition. To find out the constraint name, use the following query:
Code:
SELECT r.rdb$constraint_name
FROM rdb$relation_constraints r,
     rdb$check_constraints c
WHERE r.rdb$constraint_name = c.rdb$constraint_name
AND   r.rdb$relation_name = 'TOCCUPATION'
AND   c.rdb$trigger_name = 'STRUCTUREPARETAPE'
AND   r.rdb$constraint_type = 'NOT NULL';
Then use the name that is returned from that query to drop the constraint. Assuming the constraint is named INTEG_7:
Code:
ALTER TABLE toccupation DROP CONSTRAINT INTEG_7;
COMMIT;

Reply With Quote
  #5  
Old December 18th, 2006, 08:05 AM
Bidibulle Bidibulle is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2006
Posts: 3 Bidibulle User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 23 m
Reputation Power: 0
ok, thank you
I'll try this way.

Reply With Quote
  #6  
Old December 23rd, 2006, 06:00 AM
upscene upscene is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Posts: 223 upscene User rank is Corporal (100 - 500 Reputation Level)upscene User rank is Corporal (100 - 500 Reputation Level)upscene User rank is Corporal (100 - 500 Reputation Level)upscene User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 7 h 14 m 50 sec
Reputation Power: 8
Shammat, I don't think that's all. You actually need to modify the RDB$NULL_FLAG on RDB$FIELDS as well.


Martijn Tonies
Database Workbench - tool for InterBase, Firebird, MySQL, NexusDB, Oracle & MS SQL Server
Upscene Productions
http://www.upscene.com
My thoughts:
http://blog.upscene.com/martijn/
Database development questions? Check the forum!
http://www.databasedevelopmentforum.com
__________________
Martijn Tonies
Database Workbench: developer IDE for Firebird, MySQL, InterBase, MSSQL Server and Oracle
Upscene Productions
http://www.upscene.com

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesFirebird SQL Development > Remove NOT NULL on a column


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway