If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > Can default values in table's column be something different than constant value

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 09-17-08, 08:17
grofaty grofaty is offline
Registered User
 
Join Date: Jan 2003
Posts: 1,570
Can default values in table's column be something different than constant value

Hi,
in db2 v8.2 fp11 on Linux I would like to add default value to one column.

Sample:
Code:
COL_A COL_B
0       0
1       1
2       1
3       1
etc.
So if column A has 0 then column B gets 0, but if column A has value > 0 then column B gets 1.

I know I can define formula, but some applications are already inserting values to COL_B so I don't want to change any application.

So is there any option to use default for some "case" statement way - like "alter table mytable alter column colb set default case when a = 0 then 0 else 1 end"?

I know I can write trigger, but is there a default option that I could use just like in formula?

Thanks,
Grofaty
Reply With Quote
  #2 (permalink)  
Old 09-17-08, 08:42
przytula_guy przytula_guy is offline
Registered User
 
Join Date: Apr 2006
Location: Belgium
Posts: 1,159
I don't think that other is accepted, only default value is accepted
__________________
Best Regards, Guy Przytula
Database Software Consultant
DB2 UDB LUW Certified V7-V8-V9-V9.7 DB Admin - Dprop..
Information Server Datastage Certified
http://www.infocura.be
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On