SunQuest
           DB2 Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesDB2 Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here
  #1  
Old July 5th, 2004, 12:50 PM
Rnandam Rnandam is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 6 Rnandam User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
DB2 Equivalant for Rownum of Oracle

Few questions on DB2 equivalants for Oracle

1. What is the DB2 Equivalant of RowNum in Oracle.

2. I used to run SQLLoader command (SQLLDR) in my PC accessing Oracle in Unix. What is the equivalant of SQLLDR command in DB2 and can it be run from PC accessing DB2 in zOS.

thanks
Raja

Reply With Quote
  #2  
Old July 5th, 2004, 02:23 PM
dcaillouet's Avatar
dcaillouet dcaillouet is offline
Big Endian
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: May 2001
Location: Fly-over country
Posts: 1,173 dcaillouet User rank is Sergeant (500 - 2000 Reputation Level)dcaillouet User rank is Sergeant (500 - 2000 Reputation Level)dcaillouet User rank is Sergeant (500 - 2000 Reputation Level)dcaillouet User rank is Sergeant (500 - 2000 Reputation Level)dcaillouet User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 16 h 29 m 5 sec
Reputation Power: 24
1. What is the DB2 Equivalant of RowNum in Oracle.

ROW_NUMBER()

Take a look at the bottom of the following link: http://forums.devshed.com/t157033/s.html

2. What is the equivalant of SQLLDR command in DB2 and can it be run from PC accessing DB2 in zOS.

db2move

You might also want to look at this .

Reply With Quote
  #3  
Old July 5th, 2004, 06:47 PM
Rnandam Rnandam is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 6 Rnandam User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thanks for the reply..

When I used row_number() in the select statement - I am getting following error.

SQL error. Stmt #: 5492 Error Position: 0 Return: 8601 - [IBM][CLI Driver][DB2] SQL0440N No authorized routine named "ROW_NUMBER " of type "" having compatible arguments was found. SQLSTATE=42884
(SQLSTATE 42884) -440

here is the SQL I have used..

SELECT A.LIMIT_TYPE, row_number()
FROM PS_LIMIT_TBL A
WHERE A.EFFDT =
(SELECT MAX(A_ED.EFFDT) FROM PS_LIMIT_TBL A_ED
WHERE A.LIMIT_TYPE = A_ED.LIMIT_TYPE
AND A_ED.EFFDT <= CURRENT DATE)

Raja

Reply With Quote
  #4  
Old July 5th, 2004, 08:56 PM
dcaillouet's Avatar
dcaillouet dcaillouet is offline
Big Endian
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: May 2001
Location: Fly-over country
Posts: 1,173 dcaillouet User rank is Sergeant (500 - 2000 Reputation Level)dcaillouet User rank is Sergeant (500 - 2000 Reputation Level)dcaillouet User rank is Sergeant (500 - 2000 Reputation Level)dcaillouet User rank is Sergeant (500 - 2000 Reputation Level)dcaillouet User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 16 h 29 m 5 sec
Reputation Power: 24
I think the ROW_NUMBER function is a fairly new feature. What version of DB2 are you using?

Reply With Quote
  #5  
Old July 6th, 2004, 01:51 PM
Rnandam Rnandam is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 6 Rnandam User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Ver 7.1.

Regards

Raja Nandam

Reply With Quote
  #6  
Old July 6th, 2004, 09:44 PM
dcaillouet's Avatar
dcaillouet dcaillouet is offline
Big Endian
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: May 2001
Location: Fly-over country
Posts: 1,173 dcaillouet User rank is Sergeant (500 - 2000 Reputation Level)dcaillouet User rank is Sergeant (500 - 2000 Reputation Level)dcaillouet User rank is Sergeant (500 - 2000 Reputation Level)dcaillouet User rank is Sergeant (500 - 2000 Reputation Level)dcaillouet User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 16 h 29 m 5 sec
Reputation Power: 24
According to this web page:

http://www-106.ibm.com/developerwor...e/0110lyle.html

ROW_NUMBER was available as far back as the 6.x versions of DB2.

Every time I've seen the ROW_NUMBER function used, it is in conjunction with the OVER keyword. Try running your query by relating the ROW_NUMBER to a field and see if it works:

SELECT A.LIMIT_TYPE, row_number() OVER A.LIMIT_TYPE AS RN
FROM PS_LIMIT_TBL A
WHERE A.EFFDT =
(SELECT MAX(A_ED.EFFDT) FROM PS_LIMIT_TBL A_ED
WHERE A.LIMIT_TYPE = A_ED.LIMIT_TYPE
AND A_ED.EFFDT <= CURRENT DATE)

Reply With Quote
  #7  
Old July 8th, 2004, 11:43 AM
Rnandam Rnandam is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 6 Rnandam User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Nope. I tried the SQL got the following error.

SQL error. Stmt #: 5492 Error Position: 0 Return: 8601 - [IBM][CLI Driver][DB2] SQL0104N An unexpected token "A" was found following "". Expected tokens may include: ", FROM INTO ". SQLSTATE=42601
(SQLSTATE 42601) -104

Here is the SQL I tried.

SELECT A.LIMIT_TYPE, row_number() OVER A.LIMIT_TYPE AS RN FROM PS_LIMIT_TBL A WHERE A.EFFDT = (SELECT MAX(A_ED.EFFDT) FROM PS_LIMIT_TBL A_ED WHERE A.LIMIT_TYPE = A_ED.LIMIT_TYPE AND A_ED.EFFDT <= CURRENT DATE)

Reply With Quote
  #8  
Old July 8th, 2004, 12:21 PM
dcaillouet's Avatar
dcaillouet dcaillouet is offline
Big Endian
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: May 2001
Location: Fly-over country
Posts: 1,173 dcaillouet User rank is Sergeant (500 - 2000 Reputation Level)dcaillouet User rank is Sergeant (500 - 2000 Reputation Level)dcaillouet User rank is Sergeant (500 - 2000 Reputation Level)dcaillouet User rank is Sergeant (500 - 2000 Reputation Level)dcaillouet User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 16 h 29 m 5 sec
Reputation Power: 24
Does a query like this give you the correct results?

SELECT A.LIMIT_TYPE, row_number() OVER A.LIMIT_TYPE AS RN
FROM PS_LIMIT_TBL A
WHERE A.EFFDT = (SELECT MAX(A_ED.EFFDT)
FROM PS_LIMIT_TBL A_ED
INNER JOIN PS_LIMIT_TBL B
ON A_ED.LIMIT_TYPE = B.LIMIT_TYPE
WHERE A_ED.EFFDT <= CURRENT DATE)

Reply With Quote
  #9  
Old July 8th, 2004, 10:44 PM
Rnandam Rnandam is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 6 Rnandam User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Nope.

I have asked my DBA about the issue today and he was mentioning ROW_NUMBER() function is only valid for Windows and UNIX environments and not in DB2 Mainframe.

He was mentioning even the Sequence Number functionality is also not in DB2 Mainframe environment.

I really appreciate your effort to help me out.

I will plan for a program like SQR instead of SQL to get the desired result.

Regards
Raja

Reply With Quote
  #10  
Old July 8th, 2004, 11:12 PM
dcaillouet's Avatar
dcaillouet dcaillouet is offline
Big Endian
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: May 2001
Location: Fly-over country
Posts: 1,173 dcaillouet User rank is Sergeant (500 - 2000 Reputation Level)dcaillouet User rank is Sergeant (500 - 2000 Reputation Level)dcaillouet User rank is Sergeant (500 - 2000 Reputation Level)dcaillouet User rank is Sergeant (500 - 2000 Reputation Level)dcaillouet User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 16 h 29 m 5 sec
Reputation Power: 24
It would surprise me if IBM would remove OLAP functionality from DB2 on their most powerful hardware platform. I'm not saying your DBA is wrong because I'm sure he knows a lot more than I do. I've only used the ROW_NUMBER function on Linux/s390 so I don't have any experience using it under mainframe operating systems.

Just to humor me (and for my own knowledge) could you run a query for me on your machine? This query doesn't do anything meaningful, but it is a good test of the ROW_NUMBER function:

WITH DEVSHEDTEST AS
(SELECT LIMIT_TYPE, ROW_NUMBER() OVER (ORDER BY LIMIT_TYPE) AS RN
FROM PS_LIMIT_TBL)
SELECT LIMIT_TYPE, RN
FROM DEVSHEDTEST
WHERE RN BETWEEN 2 AND 7

Reply With Quote
  #11  
Old July 9th, 2004, 12:31 AM
Rnandam Rnandam is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 6 Rnandam User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Got the following error message -

Error: SQL0199N The use of the reserved word "AS" following "" is not valid. Expected tokens may include: "IS <HEXSTRING> <CHARSTRING> <GRAPHSTRING> ". SQLSTATE=42601
(State:42601, Native Code: FFFFFF39)

Regs
Raja

Reply With Quote
  #12  
Old June 19th, 2006, 04:52 AM
pursan pursan is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2006
Posts: 1 pursan User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 m 47 sec
Reputation Power: 0
Firebird rownum ?

Hello there.

Quick question, is there an equivalent to rownum for Firebird databases ?

Thanks

Reply With Quote
  #13  
Old January 11th, 2007, 02:02 PM
TSherr TSherr is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2007
Posts: 1 TSherr User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 7 m 2 sec
Reputation Power: 0
DB2 Equivalant for Rownum of Oracle

For DB2, try
select INT(ROWNUMBER() OVER ()) AS RNUM ....

Reply With Quote
  #14  
Old January 11th, 2007, 08:13 PM
fractalvibes fractalvibes is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Jun 2003
Location: Waco, Texas
Posts: 632 fractalvibes User rank is Sergeant (500 - 2000 Reputation Level)fractalvibes User rank is Sergeant (500 - 2000 Reputation Level)fractalvibes User rank is Sergeant (500 - 2000 Reputation Level)fractalvibes User rank is Sergeant (500 - 2000 Reputation Level)fractalvibes User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 1 Week 14 h 11 m 13 sec
Reputation Power: 22
Quote:
Originally Posted by dcaillouet
It would surprise me if IBM would remove OLAP functionality from DB2 on their most powerful hardware platform. I'm not saying your DBA is wrong because I'm sure he knows a lot more than I do. I've only used the ROW_NUMBER function on Linux/s390 so I don't have any experience using it under mainframe operating systems.

Just to humor me (and for my own knowledge) could you run a query for me on your machine? This query doesn't do anything meaningful, but it is a good test of the ROW_NUMBER function:

WITH DEVSHEDTEST AS
(SELECT LIMIT_TYPE, ROW_NUMBER() OVER (ORDER BY LIMIT_TYPE) AS RN
FROM PS_LIMIT_TBL)
SELECT LIMIT_TYPE, RN
FROM DEVSHEDTEST
WHERE RN BETWEEN 2 AND 7


Hmm - I think there are a good number of things you can do on DB2 for LUW(Linux Unix Windows) that you cannot do on DB2 mainframe (Z/OS), such as sequences. As such, UDB is constantly way ahead of mainframe DB2!

fv
__________________
...because that is the way we have always done it. We've been doing it like that for 80 Years! (How do we change that mindset?)

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesDB2 Development > DB2 Equivalant for Rownum of Oracle


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: »