dbTalk Databases Forums  

Problem with column definition of MQT

comp.databases.ibm-db2 comp.databases.ibm-db2


Discuss Problem with column definition of MQT in the comp.databases.ibm-db2 forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Arun Srini
 
Posts: n/a

Default Problem with column definition of MQT - 03-14-2011 , 08:23 AM






Hi
I defined an MQT similar to the ddl below

create mqt1(col1,col2,col3) as (select t1.col1, sum(t1.decimal_col_2)
from table1 t1, table2 t2 where t1.pkey1 = t2.pkey1 ) data initially
deferred refresh deferred;

The definition for decimal_col_2 is decimal(9,2). But when I refresh
the table and describe it, the column definition for col2 in the MQT1
is
decimal(31,2).

The part that confused me most was that there was not a single record
that satisfied the SQL that was the backend for the MQT. I researched
in the infocenter but there is no way we can specify column
definitions for user MQTs or create an exception table to move wider
rows etc.

All I want is to make sure the column definition for col2 in MQT1 is
decimal(9,2) and we use an exception table to push off rows that are
wider than this.

Thanks
Arun

Reply With Quote
  #2  
Old   
MarkB
 
Posts: n/a

Default Re: Problem with column definition of MQT - 03-14-2011 , 09:36 AM






On Mar 14, 5:23*pm, Arun Srini <arunro... (AT) gmail (DOT) com> wrote:
Quote:
Hi
I defined an MQT similar to the ddl below

create mqt1(col1,col2,col3) as (select t1.col1, sum(t1.decimal_col_2)
from table1 t1, table2 t2 where t1.pkey1 = *t2.pkey1 ) data initially
deferred refresh deferred;

The definition for decimal_col_2 is decimal(9,2). But when I refresh
the table and describe it, the column definition for col2 in the MQT1
is
decimal(31,2).

The part that confused me most was that there was not a single record
that satisfied the SQL that was the backend for the MQT. I researched
in the infocenter but there is no way we can specify column
definitions for user MQTs or create an exception table to move wider
rows etc.

All I want is to make sure the column definition for col2 in MQT1 is
decimal(9,2) and we use an exception table to push off rows that are
wider than this.

Thanks
Arun
Hi Arun,

Works as designed.
Look at the description of the SUM aggregate function:
http://publib.boulder.ibm.com/infoce.../r0000765.html
You can use an explicit casting if you want:
.... select t1.col1, cast(sum(t1.decimal_col_2) as dec(9,2)) from ...

Regards,
Mark B.

Reply With Quote
Reply




Thread Tools
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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.