![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
#3
| |||
| |||
|
|
If a column is defined as SMALLINT, and one does a SUM (or other similar function) on that column, the result is an INT. However, if the column is an INT, the result of the SUM function remains an INT. This is causing overflow on our data warehouse queries that are automatically generated by a point and click tool (such as Cognos), and we cannot ask end users to customize the SQL to cast the result as BIGINT, because it is all point and click and they never see the SQL. Any chance of getting DB2 to automatically make SUM function result into BIGINT if the table column is INT? How do I request such an enhancement from IBM? Having to define the detail columns as BIGINT just because a column may be SUM'ed will waste a lot space in our warehouse since we have billions of rows. |
#4
| |||
| |||
|
|
Op 11-09-10 09:36, Martin schreef: If a column is defined as SMALLINT, and one does a SUM (or other similar function) on that column, the result is an INT. However, if the column is an INT, the result of the SUM function remains an INT. This is causing overflow on our data warehouse queries that are automatically generated by a point and click tool (such as Cognos), and we cannot ask end users to customize the SQL to cast the result as BIGINT, because it is all point and click and they never see the SQL. Any chance of getting DB2 to automatically make SUM function result into BIGINT if the table column is INT? How do I request such an enhancement from IBM? Having to define the detail columns as BIGINT just because a column may be SUM'ed will waste a lot space in our warehouse since we have billions of rows. According to some googling, i found that DB2 functions can be overloaded So you should be able (but i dont know how) to create your own SUM() function that always returns a BIGINT |
#5
| |||
| |||
|
|
According to some googling, i found that DB2 functions can be overloaded So you should be able (but i dont know how) to create your own SUM() function that always returns a BIGINT -- Luuk |
#6
| |||
| |||
|
|
Excellent! I tried it and successed. SUM( INT(edlevel) ) |
#7
| |||
| |||
|
|
"Tonkuma" <tonk... (AT) fiberbit (DOT) net> wrote in message news:0facafad-9872-492c-8d62-2290a6918ccc (AT) s17g2000prh (DOT) googlegroups.com... Excellent! I tried it and successed. SUM( INT(edlevel) ) I don't understand how a point-and-click report writer (which only understands standard SQL functions) is going to generate the above expression. Maybe I am missing something. If current_path was "DB2ADMIN" , |
|
BTW, you don't need to cast a SUM as INT, since that is the default of doing a SUM, even if the base column is a SMALLINT. The problem is that a SUM of INT also returns INT (instead of BIGINT). I used INT(edlevel), because I couldn't find INT column in DB2 |
#8
| |||
| |||
|
|
"Luuk"<Luuk (AT) invalid (DOT) lan> wrote in message news:s23sl7-p6m.ln1 (AT) qqqqq (DOT) xs4all.nl... According to some googling, i found that DB2 functions can be overloaded So you should be able (but i dont know how) to create your own SUM() function that always returns a BIGINT -- Luuk I don't understand how a custom function is going to be used by a point-and-click report generator. |
#9
| |||
| |||
|
|
"Tonkuma" explained that in another thread.... (if you dont see it, look here: http://tinyurl.com/2w54s7x) Basically you define a new function for the user of this report-regenerator, give it the name SUM and make it return a BIGINT (which contains, of course, the SUM) -- Luuk |
#10
| |||
| |||
|
|
I did the following: 1. created the new function as DB2INST1.SUM that converts SUM to BIGINT 2. db2 SET PATH = "DB2INST1","SYSIBM","SYSFUN","SYSPROC","SYSIBMADM" 3. db2 select sum(edlevel) from emp -- this returns an INT 4. db2 select db2inst1.sum(edlevel) from emp -- this returns a BIGINT I need number 3 above to return a BIGINT. I cannot have the query tool customize the SQL in any way. How did you created the table emp? |
![]() |
| Thread Tools | |
| Display Modes | |
| |