Writing a record to a physical file from CL

750 pts.
Tags:
AS 400
CL Program
Can I write a record to a physical file from CL? Once I do a test on a record, and before I delete the record, I wanted to write it to a physical file so later I can query over it to list what records were deleted.


Software/Hardware used:
V7R1M0
1

Answer Wiki

Thanks. We'll let you know when a new response is added.
If you are not familiar with SQL functions, which would be the way to go there is a way.  If it does have to be in a CL application, iIt’s possible but not a clean process. You could use the CPYF command and using a select key and the *ADD on the TOFILE put them in the file..

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.
  • TheRealRaven
    Although it's not quite appropriate, database rows can be written from CL. CL is a 'Control Language' rather than a database language, but it's advanced enough that it can call essentially call the same database APIs that C can.

    In addition, SQL INSERT statements can be built and executed in CL CL commands to execute SQL are RUNSQLSTM and RUNSQL. Also, parameters can be passed into QM queries to execute SQL INSERTs with STRQMQRY. And the CL STRQSH (or just QSH) command can run the QShell db2 utility to run SQL statements.
    35,610 pointsBadges:
    report
  • WoodEngineer
    Check out adding a physical file trigger (ADDPFTRG) with event of *Delete.  This will automatically capture a record before it is deleted.  No changes to any of your programs required.
    8,225 pointsBadges:
    report
  • Rrbond07
    Thank you all for your input. I did use SQL in my CL program and utilized INSERT into a file, and it worked great. I needed to write records into another file after tests were done on a record. Afterwards this other file was used to delete records I wanted deleted. It worked great.
    750 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: