Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
SQL code -190

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
View previous topic :: :: View next topic  
Author Message
guptae

Moderator


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

PostPosted: Wed Jun 08, 2011 4:22 pm    Post subject: SQL code -190
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

Global Moderator


Joined: 14 Mar 2007
Posts: 10327
Location: italy

PostPosted: Wed Jun 08, 2011 4:34 pm    Post subject: Reply to: SQL code -190
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    Post subject:
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: 1187
Location: Bangalore,India

PostPosted: Wed Jun 08, 2011 7:14 pm    Post subject:
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: 658
Location: Whitby, ON, Canada

PostPosted: Wed Jun 08, 2011 7:40 pm    Post subject:
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    Post subject:
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    IBMMAINFRAMES.com Support Forums -> DB2 All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Speed-up/reduce CPU use of code prino PL/I & Assembler 0 Tue Sep 26, 2017 12:05 am
This topic is locked: you cannot edit posts or make replies. how to code for GDG in Rexx cvnlynn CLIST & REXX 13 Wed Aug 09, 2017 9:13 pm
This topic is locked: you cannot edit posts or make replies. rexx code to create a ps file Bharath Vikraman CLIST & REXX 4 Mon Aug 07, 2017 10:30 am
No new posts I want to retire TRX and use only Rex... Abhinav Sharma CLIST & REXX 6 Sat Jul 29, 2017 2:53 am
No new posts UNIT=AFF for Easytrieve code gandikk JCL & VSAM 7 Wed Jul 12, 2017 11:42 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us