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 > Alter Data Type in DB2

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-18-10, 01:44
arbenhesed arbenhesed is offline
Registered User
 
Join Date: Nov 2010
Posts: 1
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
Reply With Quote
  #2 (permalink)  
Old 11-18-10, 04:45
dbzTHEdinosaur dbzTHEdinosaur is offline
Registered User
 
Join Date: Jun 2007
Location: germany
Posts: 96
how about a check constraint? >0 <1000
__________________
Dick Brenholtz, Ami in Deutschland
Reply With Quote
  #3 (permalink)  
Old 11-19-10, 09:21
Cougar8000 Cougar8000 is offline
Registered User
 
Join Date: Nov 2005
Location: IL
Posts: 554
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.1.0.2 os 5.3.0.0
Reply With Quote
  #4 (permalink)  
Old 11-23-10, 03:55
dbzTHEdinosaur dbzTHEdinosaur is offline
Registered User
 
Join Date: Jun 2007
Location: germany
Posts: 96
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
Reply With Quote
  #5 (permalink)  
Old 11-23-10, 09:44
Cougar8000 Cougar8000 is offline
Registered User
 
Join Date: Nov 2005
Location: IL
Posts: 554
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.1.0.2 os 5.3.0.0
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