Results 1 to 5 of 5
  1. #1
    Join Date
    Nov 2010
    Posts
    1

    Unanswered: Alter Data Type in DB2

    hi,

    I use DB2 V8.

    i need to create a SMALLINT column but it will alow upto 5 digits to be entered. but i have to make it to allow not more than 3 digits.

    i cant change it to CHAR. I need to have it as INTIGER

  2. #2
    Join Date
    Jun 2007
    Location
    germany
    Posts
    155
    how about a check constraint? >0 <1000
    Dick Brenholtz, Ami in Deutschland

  3. #3
    Join Date
    Nov 2005
    Location
    IL
    Posts
    557
    Enforcing business rules on db? Personally I think it is a bad design. Business rules should be enforced at the application level. Person should not be able to type in 5 digit in the first place if you only want them to type 3.
    --
    IBM Certified DBA on DB2 for Linux, UNIX, and Windows

    DB2 v9.7.0.6 os 6.1.0.0

  4. #4
    Join Date
    Jun 2007
    Location
    germany
    Posts
    155
    Quote Originally Posted by Cougar8000 View Post
    Enforcing business rules on db? Personally I think it is a bad design. Business rules should be enforced at the application level. Person should not be able to type in 5 digit in the first place if you only want them to type 3.
    and how to enforce the business rules when data is loaded to the table,
    inserted via SPUFI or QMF,
    another application is written (such as web driven update)??????????????

    Maintaining the 'business purity' of data is also accomplished with
    Constraints and Triggers.

    Of what use is a constraint if not to enforce Business Rules?????????
    Dick Brenholtz, Ami in Deutschland

  5. #5
    Join Date
    Nov 2005
    Location
    IL
    Posts
    557
    Just because something is there, does not mean you have to use it.

    Performing this check on the DB side is doable, but why if it can be done at the front end? It will cost less to do it at the front end as you will not have network traffic, you will not have locks. It will be faster and be able to provide end user with correct customizable msg.

    If it is done via bulk load from a data file. Then having a small job do data validation prior to loading can speed up your load as well.

    I would use triggers if I absolutely had to/were not allowed to enforce it at the app side. Something I had to do in regards to CC encryption that HAD to be done at the DB side coming in and going out. I did not like, but I did it. It was done using triggers.
    --
    IBM Certified DBA on DB2 for Linux, UNIX, and Windows

    DB2 v9.7.0.6 os 6.1.0.0

Posting Permissions

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