I am applying dense_rank in a cursor. When I run the sql in the editor I get the correct ranking in consecutive order. But when I run it in a cursor and execute the procedure to insert into the table, the ranking goes off. I am not sure what I am doing incorrect here.

--cursor SRCBAL_cur is
-- 1. For PDC to PDC transfer rule from 7 PDC's to 8 PDC's
SELECT effective_date, allocation_percent,
dense_rank() over (partition by substr(Source_TO_org_code, 5,7) order by pdc_rank asc ) as rank1,
PDC_Rank,
item_name,
Source_TO_org_code,
receipt_organization_code, source_FROM_org_code
FROM (
SELECT /*+ Parallel (SOI,12) Parallel(ISI,12) Parallel(SI,12)*/
distinct SYSDATE AS effective_date,
100 AS allocation_percent,
RSM.SEQ_NUM AS PDC_RANK,
ISI.item_name ,
SOI.organization_code AS Source_TO_org_code,
SOI.organization_code AS receipt_organization_code,
ISI.organization_code AS source_FROM_org_code
FROM APSR_ORG_RCVR_SNDR_MAT RSM, APSR_SP_SUPLR_ORG_ITEM_NR SOI,
APSR_ITEM_STOCK_INDICATORS_NR ISI, APSR_SYSTEM_ITEMS SI
WHERE SI.item_name = ISI.item_name
and SI.organization_code = ISI.organization_code
AND SI.item_name = SOI.item_name
AND SOI.item_name = ISI.item_name
and RSM.RCVR_ORG_CODE = 'LEG:770'
and SOI.organization_code = RSM.RCVR_ORG_CODE
AND ISI.organization_code = RSM.SNDR_ORG_CODE
and ISI.DISTRIB_TYPE_CD = '1')
where item_name = '03122222002'
and receipt_organization_code = 'LEG:770';

RANK1 -- PDC_RANK
---------------------
1 -- 1
2 -- 3

when I run the procedure and check the data in the table it appears as:
RANK1
------
1
3

I am not sure why the 2 is turning into 3. Any ideas. Please help.