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 > using upper with OLAP function

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-26-09, 11:26
ramanay ramanay is offline
Registered User
 
Join Date: Dec 2008
Posts: 10
using upper with OLAP function

hi,
I have a query like

select * from( SELECT ROW_NUMBER() OVER(ORDER BY SNum) AS row,SNum

from atm.asnum

where SNum<> ''
and UPPER(SNum)=UPPER('atal'))

where row >=2 and row <=20

I get the error SQL0255- function not supported.
Is there any other way to use the upper with row_number . I tried translate as well but same error.
Reply With Quote
  #2 (permalink)  
Old 01-26-09, 13:07
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
Which DB2 version and platform are you using? I am asking because SQL0255 is not a valid error message on DB2 LUW.

What have you tried so far to narrow down the problem?
__________________
Knut Stolze
IBM DB2 Analytics Accelerator
IBM Germany Research & Development
Reply With Quote
  #3 (permalink)  
Old 01-26-09, 13:15
ramanay ramanay is offline
Registered User
 
Join Date: Dec 2008
Posts: 10
Its a V5R4 on I5/OS.

I tried to run the SELECT SNum

from atm.asnum

where SNum<> ''
and UPPER(SNum)=UPPER('atal')
It runs fine.


Thanks
-R
Reply With Quote
  #4 (permalink)  
Old 01-26-09, 14:30
Peter.Vanroose Peter.Vanroose is offline
Registered User
 
Join Date: Sep 2004
Location: Belgium
Posts: 1,079
Quote:
Originally Posted by ramanay
select * from( SELECT ROW_NUMBER() OVER(ORDER BY SNum) AS row,SNum
from atm.asnum
where SNum<> ''
and UPPER(SNum)=UPPER('atal'))
where row >=2 and row <=20

I get the error SQL0255- function not supported.
Could it be that your DB2 version does not support the ROW_NUMBER() function?
If so, the following would be "almost as good" (apart from an extra first row):
Code:
SELECT SNum FROM atm.asnum
WHERE UPPER(SNum)=UPPER('atal')
ORDER BY SNum
FETCH FIRST 20 ROWS ONLY
__________________
--_Peter Vanroose,
__IBM Certified Database Administrator, DB2 9 for z/OS
__IBM Certified Application Developer
__ABIS Training and Consulting
__http://www.abis.be/
Reply With Quote
  #5 (permalink)  
Old 01-26-09, 14:48
ramanay ramanay is offline
Registered User
 
Join Date: Dec 2008
Posts: 10
Hi,
The row_number function worked fine prior to using the upper.
Its the combination which of row_number and upper which fails.Both work fine independent of each other. And i have to use row_number as it is required for paging to retrieve specified number of records with startCount and endCount.
Reply With Quote
  #6 (permalink)  
Old 01-26-09, 14:59
Peter.Vanroose Peter.Vanroose is offline
Registered User
 
Join Date: Sep 2004
Location: Belgium
Posts: 1,079
Try the following:
Code:
select *
from ( select ROW_NUMBER() OVER(ORDER BY SNum) AS row, SNum
       from   atm.asnum
       where  UPPER(SNum)=UPPER('atal')) t
where row between 2 and 20
(I.e., I added the alias "t" for the nested table expression.)

B.t.w., are you sure that SNum is a textual column?
Maybe you need to explicitly cast it to VARCHAR(64) or something before applying UPPER to it.
__________________
--_Peter Vanroose,
__IBM Certified Database Administrator, DB2 9 for z/OS
__IBM Certified Application Developer
__ABIS Training and Consulting
__http://www.abis.be/
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