Results 1 to 2 of 2
  1. #1
    Join Date
    Jan 2003
    Posts
    1,605

    Unanswered: 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

  2. #2
    Join Date
    Apr 2006
    Location
    Belgium
    Posts
    2,514
    Provided Answers: 11
    I don't think that other is accepted, only default value is accepted
    Best Regards, Guy Przytula
    Database Software Consultant
    Good DBAs are not formed in a week or a month. They are created little by little, day by day. Protracted and patient effort is needed to develop good DBAs.
    Spoon feeding : To treat (another) in a way that discourages independent thought or action, as by overindulgence.
    DB2 UDB LUW Certified V7-V8-V9-V9.7-V10.1-V10.5 DB Admin - Advanced DBA -Dprop..
    Information Server Datastage Certified
    http://www.infocura.be

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •