Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 2005
    Posts
    7

    Unanswered: Can I spool the result of a statement to different file based on some criteria

    such as when using group by, I want every group go to a seperate file.

    Is it possible? otherwise, the huge table will be accessed many time.

  2. #2
    Join Date
    May 2004
    Location
    Dominican Republic
    Posts
    721
    If you are concerned about hitting the table "many time", then I would suggest you use some OS utilities ( like split or awk ) to split the file after you spool it out of the DB.

  3. #3
    Join Date
    Jun 2003
    Location
    West Palm Beach, FL
    Posts
    2,713

    Cool


    -- OR -- Try something like this:
    PHP Code:
    Set Pages 0 Feed Off Ver Off Term Off Trims On Lin 200
    Spo 
    /tmp/_MyScript.sql
    Prompt Set Pages 55 Feed On Ver On Term On Trims On Lin 200
    Select 
    'Spo Dept_'||department_id||'.txt'||Chr(10)
         ||
    'Select * From employees Where department_id = '''
         
    ||department_id||''';'||Chr(10)
      
    From employees
      group by department_id
      order by department_id
    /
    Spo Off  
    @/tmp/_MyScript.sql 


    Last edited by LKBrwn_DBA; 11-21-06 at 11:52.
    The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •