IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

SQL code -190


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
guptae

Moderator


Joined: 14 Oct 2005
Posts: 1208
Location: Bangalore,India

PostPosted: Wed Jun 08, 2011 4:22 pm
Reply with quote

Hello All,

I am finding strange problem. I have one table which have few column out of all two of them are

CAS4_ADJ_QTY decimal (15,0)
CAS7_ADJ_QTY decimal(15,0)
both are nullable . I want them to alter as decimal(15,3). Forgot to mention that my test table is empty. I am using below query.

Code:
alter table t6qjdbg.CLAIM_REMIT_CAS
alter column CAS4_ADJ_QTY
set data type decimal(15,3);


Code:
alter table t6qjdbg.CLAIM_REMIT_CAS
alter column CAS7_ADJ_QTY
set data type decimal(15,3);


For first query i received sqlcode -190

Code:
DSNT408I SQLCODE = -190, ERROR:  THE ATTRIBUTES SPECIFIED FOR THE COLUMN CAS4_ADJ_QTY ARE NOT COMPATIBLE WITH THE EXISTING
  COLUMN DEFINITION 


while next query executed successfuily.

What might be the reason. Please help. I know we can drop and recreate the table with new def of fields. but i want to work with Alter as prod data is huge.
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Wed Jun 08, 2011 4:34 pm
Reply with quote

most probably the original column definitions are not the same !
Back to top
View user's profile Send private message
GuyC

Senior Member


Joined: 11 Aug 2009
Posts: 1281
Location: Belgium

PostPosted: Wed Jun 08, 2011 4:50 pm
Reply with quote

DECIMAL(p,s) to DECIMAL(q,t) : q>=p and (q-t)>=(p-s)
so (15,0) to (15,3) is not possible : (15 - 3) < (15 - 0)
(15,0) to (18,3) or (12,0) to (15,3) are possible

(Stating DB2 version is also nice)
Back to top
View user's profile Send private message
guptae

Moderator


Joined: 14 Oct 2005
Posts: 1208
Location: Bangalore,India

PostPosted: Wed Jun 08, 2011 7:14 pm
Reply with quote

Hello GuyC,

I m using DB2 V9.1. and i dont agree DECIMAL(P,S) is going to use P bytes do whether its decimal(p,s) or decimal(p,s+2) would not be any issue,The field length will not changed only the number of decimal places - so, the field is defined
here is a clip

Code:
Column Name        Col No Col Type Length Scale 
*                       * *             *      *
-----------------> ------ -------- ------ ------
CAS4_ADJ_QTY            9 DECIMAL      15      3 <===============  3 decimal places
CAS5_ADJ_RSN_CD        10 CHAR          5      0
CAS6_ADJ_AMT           11 DECIMAL      18      2
CAS7_ADJ_QTY           12 DECIMAL      15      0 <===============  0 decimal places
Back to top
View user's profile Send private message
don.leahy

Active Member


Joined: 06 Jul 2010
Posts: 765
Location: Whitby, ON, Canada

PostPosted: Wed Jun 08, 2011 7:40 pm
Reply with quote

I agree that the size of the new column is the same, but DB2 disallows the change because of the risk of truncation. For example, if the existing column contains
Code:
999 999 999 999 999 (spaces shown for readabilty)
and DB2 allowed you to ALTER it to (15,3) the field would have to be truncated to
Code:
999 999 999 999 000 (decimal point implied)

The bottom line is that DB2 is preventing you from damaging your data.
Back to top
View user's profile Send private message
GuyC

Senior Member


Joined: 11 Aug 2009
Posts: 1281
Location: Belgium

PostPosted: Wed Jun 08, 2011 9:21 pm
Reply with quote

1) "DECIMAL(p,s) to DECIMAL(q,t) : q>=p and (q-t)>=(p-s) "
I didn't invent this. It's straight out of the SQL reference guide.

2) What don.leahy said
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts run rexx code with jcl CLIST & REXX 15
No new posts Compile rexx code with jcl CLIST & REXX 6
No new posts REXX code to expand copybook in a cob... CLIST & REXX 2
No new posts VSAM return code 23 - for a Random read COBOL Programming 4
No new posts Monitoring production job progress. N... JCL & VSAM 4
Search our Forums:

Back to Top