How to create a single member file for each member of a given multi-member file?

185 pts.
Tags:
AS/400
AS/400 database
AS/400 DB2
CPYF
Let the file be 'Employee' and its members be 'Trainee', 'Associate', 'Professional', and 'Expert'. I wish to cut the superset of 'Employee', and just get dedicated PFs for 'Trainee', 'Associate', 'Professional' and 'Expert' (so that they can be queried as a first member.)

Software/Hardware used:
ibm i series

Answer Wiki

Thanks. We'll let you know when a new response is added.

Two ways to do this:

1. Create a LF over the PF and include *ALL members
2. Do  CPYF EMPLOYEE yourlib/EMPLOYEALL *ALL EMPLOYEALL CRTFILE(*YES)

Discuss This Question: 11  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.
  • ToddN2000
    The steps Charlie mentioned will do it. The possible problem you may have is how to distinguish which type of data record you are reading. Why not just use an OVRDBF of the existing file to access the member(s) you need?
    113,580 pointsBadges:
    report
  • Splat
    CharlieBrowne, I think your CPYF should read

    CPYF FROMFILE(EMPLOYEE) 
         TOFILE(TRAINEE)    
         FROMMBR(TRAINEE)   
         CRTFILE(*YES)      
    12,650 pointsBadges:
    report
  • GregManzo
    or 3. Redesign your database to hold a Type on the record and put them all in one member in the first place.

    "If builders built buildings the way computer professionals designed systems, the first woodpecker along would destroy civilisation."
    2,845 pointsBadges:
    report
  • WoodEngineer
    Question: Is this a one-time requirement or does it need be repeated from time to time?
    8,130 pointsBadges:
    report
  • ToddN2000
    I went back and looked at this again. I agree with Splat. Charlie's answer will consolidate all the members into 1 file with one member name. You are looking to take a single file with 4 members and create a new PF for each of the 4 members. You would do that following Splats example. I would still prefer to use the OVRDBF because there is only one set of data to maintain. IF you copy it out into individual file you may have data sync issues.
    113,580 pointsBadges:
    report
  • CharlieBrowne
    To Splat:
    You have an error in your correction of my copyf.
    My statement will copy*ALL members from file EMPLOYEE into a file call EMPLOYEEALL with the member name EMPLOYEEALL.

    Your statement only copies a single member call TRAINEE into the new new file.
    62,355 pointsBadges:
    report
  • RossHowatson
    Since the request contains the phrase "so that they can be queried as a first member." then one would ASSUME that the Query/400 is being used. As such one would need to do an OVRDBF command on the Library/PhysicalFile/MemberName to the required name. If the Query is within SQL then one can use the CREATE ALIAS command within SQL to define an override to access the member directly since Tables with multiple members is not the normal way within SQL.
    560 pointsBadges:
    report
  • Splat
    CharlieBrowne, please go back & read what rajat01 was asking for.
    12,650 pointsBadges:
    report
  • ToddN2000
    Try something like this:
    CPYF       FROMFILE(MYLIB/EMPLOYEE) +                   
                 TOFILE(MYLIB/EMP_ALL) FROMMBR(TRAINEE) +   
                 CRTFILE(*YES)                              
                                                            
    CPYF       FROMFILE(MYLIB/EMPLOYEE) +                   
                 TOFILE(MYLIB/EMP_ALL) FROMMBR(ASSOCIATE) + 
                 MBROPT(*ADD) CRTFILE(*NO)                  
                                                            
    CPYF       FROMFILE(MYLIB/EMPLOYEE) +                   
                 TOFILE(MYLIB/EMP_ALL) FROMMBR(PROFESSION) +
                 MBROPT(*ADD) CRTFILE(*NO)                  
                                                            
    CPYF       FROMFILE(MYLIB/EMPLOYEE) +                   
                 TOFILE(MYLIB/EMP_ALL) FROMMBR(EXPERT) +    
                 MBROPT(*ADD) CRTFILE(*NO)                  
                                                            
    113,580 pointsBadges:
    report
  • CharlieBrowne
    Sorry Splat.
    I did not read this correctly.
    62,355 pointsBadges:
    report
  • Splat
    CharlieBrowne, no worries. It happens to me often enough.
    12,650 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

Thanks! We'll email you when relevant content is added and updated.

Following

Share this item with your network: