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 > Help me convert this to Oracle

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 03-12-10, 04:40
sandhyaproddaturi sandhyaproddaturi is offline
Registered User
 
Join Date: Mar 2010
Posts: 1
Help me convert this to Oracle

INSERT INTO PS_AF_PRWK_CNT_T(PROCESS_INSTANCE
, AF_STORE_NUM
,EMPLID
,WEEK_END_DT
,DAYOFWEEK
,COUNTER ) WITH n(PROCESS_INSTANCE
,AF_STORE_NUM
,EMPLID
,WEEK_END_DT
,DAYOFWEEK) AS (
SELECT PROCESS_INSTANCE,AF_STORE_NUM
,EMPLID
,WEEK_END_DT
,DAYOFWEEK
FROM PS_AF_PRWK_SCH_T WHERE EMPLID <> 'UNFILL'
UNION ALL
SELECT PROCESS_INSTANCE
,nplus1.AF_STORE_NUM
,nplus1.EMPLID
,nplus1.WEEK_END_DT
,nplus1.DAYOFWEEK
FROM PS_AF_PRWK_SCH_T nplus1
,n
WHERE n.DAYOFWEEK = nplus1.DAYOFWEEK-1
AND n.EMPLID=nplus1.EMPLID
AND n.AF_STORE_NUM=nplus1.AF_STORE_NUM
AND n.WEEK_END_DT=nplus1.WEEK_END_DT )
SELECT PROCESS_INSTANCE
,AF_STORE_NUM
,EMPLID
,WEEK_END_DT
,DAYOFWEEK
, COUNT(*)
FROM n
WHERE DAYOFWEEK=7
GROUP BY AF_STORE_NUM ,EMPLID,WEEK_END_DT,DAYOFWEEK
Reply With Quote
  #2 (permalink)  
Old 03-12-10, 06:54
tonkuma tonkuma is offline
Registered User
 
Join Date: Feb 2008
Location: Japan
Posts: 2,177
You can ask on Oracle forum.
Oracle - dBforums
Reply With Quote
  #3 (permalink)  
Old 03-12-10, 07:25
n_i n_i is offline
:-)
 
Join Date: Jun 2003
Location: Toronto, Canada
Posts: 4,448
Convert the common table expression into a subselect.
Reply With Quote
  #4 (permalink)  
Old 03-12-10, 07:40
tonkuma tonkuma is offline
Registered User
 
Join Date: Feb 2008
Location: Japan
Posts: 2,177
The common table expression "n" is a recursive CTE.
So, it might be converted to Oracle by using CONNECT BY syntax.
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