Question : Retrieving Large ResultSets

I have the SQL statement below that returns 100s of thousands of records.  When I run this SQL statement in the application being used it times out with a java heap size and memory runs out on the server.  So is there a way for me to get the total count of records using say count(*) and then break the retun results up in chunks?  So for example I would run the select count(*), and let's say I get a return result of 10 records.  Could I then perform the below sql statement to say give me the first 5 records, I would process those records and then increment the variable based on the count(*) to get the next 5 records?  I just don't know how to do that in SQL or what modifications I would need to make on the SQL statement below.  thanks in advance.
Code Snippet:
1:
SELECT A.EMPLID, A.EMPL_RCD, A.BIRTHDATE, A.DT_OF_DEATH, A.COUNTRY_NM_FORMAT, A.NAME, A.NAME_INITIALS, A.NAME_PREFIX, A.NAME_SUFFIX, A.NAME_ROYAL_PREFIX, A.NAME_ROYAL_SUFFIX, A.NAME_TITLE, A.LAST_NAME_SRCH, A.FIRST_NAME_SRCH, A.LAST_NAME, A.FIRST_NAME, A.MIDDLE_NAME, A.SECOND_LAST_SRCH, A.SECOND_LAST_NAME, A.PREF_FIRST_NAME, A.COUNTRY, A.ADDRESS1, A.ADDRESS2, A.ADDRESS3, A.ADDRESS4, A.CITY, A.NUM1, A.NUM2, A.HOUSE_TYPE, A.ADDR_FIELD1, A.ADDR_FIELD2, A.ADDR_FIELD3, A.COUNTY, A.STATE, A.POSTAL, A.HOME_PHONE, A.SEX, A.MAR_STATUS, A.MILITARY_STATUS, A.DISABLED, A.DISABLED_VET, A.ETHNIC_GROUP, A.ORIG_HIRE_DT, A.PER_ORG, A.CMPNY_SENIORITY_DT, A.SERVICE_DT, A.BUSINESS_TITLE, A.EFFDT, A.EFFSEQ, A.HIRE_DT, A.EXPECTED_RETURN_DT, A.TERMINATION_DT, A.LAST_DATE_WORKED, A.SUPERVISOR_ID, A.BUSINESS_UNIT, A.DEPTID, A.JOBCODE, A.EMPL_STATUS, A.ACTION, A.ACTION_DT, A.ACTION_REASON, A.LOCATION, A.JOB_ENTRY_DT, A.DEPT_ENTRY_DT, A.SHIFT, A.REG_TEMP, A.FULL_PART_TIME, A.FLSA_STATUS, A.COMPANY, A.PAYGROUP, A.EMPL_TYPE, A.STD_HOURS, A.STD_HRS_FREQUENCY, A.REG_REGION, A.FTE, A.EEO_CLASS, A.COMP_FREQUENCY, A.SETID_DEPT, A.SETID_JOBCODE, A.SETID_LOCATION, A.JOB_FAMILY, A.JOBTITLE, A.JOBTITLE_ABBRV, A.DEPTNAME, A.DEPTNAME_ABBRV, A.REHIRE_DT, A.WORK_PHONE, A.SUPERVISOR_NAME, A.FDC_ACQUISITION_DT, A.FDC_ELIG_REHIRE, A.FDC_ELIG_REH_DESCR, A.FDC_REH_ELIG_DATE, A.FDC_MAIL_DROP, A.FDC_RTN_LEAVE_DT, A.FDC_TRANSFER_DT, A.FDC_EMAIL_ADDR, A.FDC_ESERV_USER_FLG, A.FDC_PURCH_AUTH_LVL, A.EMPL_CLASS, A.COMPANY_DESCR, A.LOCATION_DESCR, A.FDC_PAYROLL_ID  FROM PS_FD_SOA_NSEMP_VW A, PS_EMPLMT_SRCH_QRY A1  WHERE A.EMPLID = A1.EMPLID  AND A.EMPL_RCD = A1.EMPL_RCD AND A.OPRID = A1.OPRID AND A1.OPRID = 'USER'
Open in New Window Select All

Answer : Retrieving Large ResultSets

Try this

 SELECT
 A.EMPLID      ,
 BIRTHDATE        
    FROM
  (
  SELECT rownum r      ,
    A.EMPLID            ,
    A.BIRTHDATE        
     FROM
PS_EMPLMT_SRCH_QRY A1,
PS_FD_SOA_NSEMP_VW A
WHERE A.EMPLID = A1.EMPLID
AND A.EMPL_RCD   = A1.EMPL_RCD
AND A.OPRID      = A1.OPRID
AND A1.OPRID = 'USER'
      )
     
  WHERE
  R > 5
  AND R < 11
Random Solutions  
 
programming4us programming4us