clear physical file member question

pts.
Tags:
Application development
AS/400
Backup and Recovery
CLP
DataCenter
RPG
Security
is it possible for me to only clear certain records of a physical while leaving certain records available? I have a file with thousands of records, but I only need the records starting with a certain date. How can I delete everything prior to the date that i need with out totally wiping out the entire file with the CLRPFM command?

Answer Wiki

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

CLRPFM doesn’t delete individual records, so it is all or nothing. Try:
DELETE FROM foobar
WHERE date_column < :certain_date;

Discuss This Question: 3  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.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • astradyne
    If you're not into SQL you can do this using the CPYF command. First create a duplicate copy of the file to work from: CRTDUPOBJ OBJ(myfile) FROMLIB(mylib) OBJTYPE(*FILE) TOLIB(QTEMP) Then, use the CPYF command to copy the file over the original whilst removing the records you don't want: CPYF FROMFILE(QTEMP/myfile) TOFILE(mylib/myfile) MBROPT(*REPLACE) INCREL((*IF datefield *GE datevalue)) The INCREL parameter tells the system to only include records where a condition is met. In this case we're checking the value of a datefield against it's contents. For this to work your date would have to be in YYYYMMDD order. If it's a date data type then you would probably need to test against something like d'YYYY-MM-DD'. Hope it helps Jonathan www.astradyne-uk.com
    370 pointsBadges:
    report
  • TomLiotta
    If a CPYF is used, a second copy of the file is created. Before copying this result back, review it carefully to be sure that it contains all of the desired records. If SQL is used to DELETE large sets of records, run the statement first as a SELECT * statement to see a list of selected records. If only the records you want to delete are in the list, run the same statement after typing DELETE over SELECT *. Tom
    125,585 pointsBadges:
    report
  • BigKat
    I can't tell you how many times SELECTing before DELETEing has prevented major headaches! :)
    8,350 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.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

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

Following