Article View: borland.public.interbase.sql
Article #11088Re: Setting not NULL constraint afterwards
From: Martijn Tonies
Date: Thu, 12 Dec 2002 15:17
Date: Thu, 12 Dec 2002 15:17
93 lines
3278 bytes
3278 bytes
How about adding a trigger (that fires last) that checks the field for NULL and sets it to 0 as default? And, of course, the NOT NULL constraint. -- With regards, Martijn Tonies InterBase Workbench - the developer tool for InterBase & Firebird Firebird Workbench - the developer tool for Firebird Upscene Productions http://www.upscene.com "This is an object-oriented system. If we change anything, the users object." > The problem lies a little deeper since there are certain triggers and > other activities that cretes new lines to that table. I need to make sure > that there is never a line with NULL value. > > The table should be like this > > CREATE TABLE MYMISTAKE ( > NR INTEGER NOT NULL, > PROBLEM INTEGER NOT NULL, > ..... > ) > > or > > CREATE TABLE MYMISTAKE ( > NR INTEGER NOT NULL, > PROBLEM INTEGER DEFAULT 0, > ..... > ) > > but now it is > > CREATE TABLE MYMISTAKE ( > NR INTEGER NOT NULL, > PROBLEM INTEGER, > ..... > ) > > so I should be able to add that constraint which make that value = 0 > if the insert don't set that PROBLEM field > > Mika Parjanen > > "Martijn Tonies" <m.tonies@upscene_remove.com> kirjoitti viestiss๏ฟฝ > news:3df841c4@newsgroups.borland.com... > > Hi, > > > > > just a simple question: > > > > > > How can I set a field NOT NULL constraint afterwards. > > > There is a lot of data in that table and too much depencies > > > so I cannot drop and recreate that field again. > > > > > > I suppose "DEFAULT 0" would also be enough. > > > > In IB6 or higher, it should be. > > > > Also simply filling the column yourself, > > UPDATE ... SET MYCOL = 0 WHERE MYCOL IS NULL > > > > would do the same thing. > > > > > This is a problem because I have triggers which > > > increment and decrement that value and that can't be done > > > if value is NULL. > > > > > > > > -- > > > > With regards, > > > > Martijn Tonies > > InterBase Workbench - the developer tool for InterBase & Firebird > > Firebird Workbench - the developer tool for Firebird > > Upscene Productions > > http://www.upscene.com > > > > "This is an object-oriented system. > > If we change anything, the users object." > > > > > >
Technical Details
Message-ID:
<3df8a7e5@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-03!sn-xit-01!sn-xit-09!supernews.com!news.maxwell.syr.edu!feedme.news.mediaways.net!news.uni-x.net!newsgroups.borland.com!not-for-mailReferences:
<3df8363f$1@newsgroups.borland.com> <3df841c4@newsgroups.borland.com> <3df89be8@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII X-Google-Thread: 114a0e,71b50d57bbdad000 X-Google-Attributes: gid114a0e,public X-Google-ArrivalTime: 2002-12-12 07:15:28 PST From: "Martijn Tonies" <m.tonies@upscene_remove.com> Newsgroups: borland.public.interbase.sql References: <3df8363f$1@newsgroups.borland.com> <3df841c4@newsgroups.borland.com> <3df89be8@newsgroups.borland.com> Subject: Re: Setting not NULL constraint afterwards Date: Thu, 12 Dec 2002 16:17:38 +0100 Lines: 95 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 NNTP-Posting-Host: 212.238.179.102 Message-ID: <3df8a7e5@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1039706085 212.238.179.102 (12 Dec 2002 07:14:45 -0800) Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-03!sn-xit-01!sn-xit-09!supernews.com!news.maxwell.syr.edu!feedme.news.mediaways.net!news.uni-x.net!newsgroups.borland.com!not-for-mail