Update a file from CL program

2505 pts.
Tags:
AS/400
CL Program
Why it is said we cannot update a file through CL? We can use RunsqlStm or Runqry to update a record right? If I select a particular record by using Rcvf or opnqryf and then perform runqry/runsqlstm, will it pick the desired record?

Software/Hardware used:
AS400

Answer Wiki

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

If you rewad a record with RCVF, you can use SQL to update it if you have unique data elements to select the record.

———————————————————

Anyone suggesting that CL cannot update records within a file has not been keeping up with CL. You can certainly use the RUNSQL command (on 6.1 and 7.1 ) as an update mechanism (with alternative SQL implementations also available). You can also update records, without SQL, using the CL for Files product documented here.  CLF provides support starting with V5R4 and the update can be done using only the no-charge runtime option or with the fee-based CL precompiler (a productivity option). Please note that I am one of the CLF developers. Bruce Vining

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
  • TomLiotta
    If I select a particular record by using Rcvf or opnqryf and then perform runqry/runsqlstm, will it pick the desired record?   No. They will be unrelated.   It is said that CL cannot update files because there is no native support in CL for updating files.   You can create CL commands to update files if you wish since CL is extensible. (Bruce Vining makes commands like those available.) Or you can access facilities in other languages such as SQL or C by using the RUNSQLSTM or RUNSQL commands or by calling APIs.   Tom
    125,585 pointsBadges:
    report
  • RamvishakRamesh
    Thank you Tom for the clarification.
    2,505 pointsBadges:
    report
  • TomLiotta
    If you rewad a record with RCVF, you can use SQL to update it if you have unique data elements to select the record.   You can issue a SQL UPDATE against a record read by RCVF, but there is no connection between the two operations (other than the logic you write). The operations are done against two unconnected open data paths.   For example, although you can issue a SQL UPDATE, it cannot be a positioned UPDATE (i.e., an UPDATE ... WHERE CURRENT OF ...). The UPDATE must include a WHERE clause that identifies a row by column values. An UPDATE may be issued against the RCVF record or any other record, including one from a different table. The operations are separate.   The RUNSQL command should be thought more like an embedded SQL EXECUTE IMMEDIATE in RPG or COBOL than like a 'native CL I/O' statement. Similar considerations for commitment control apply for example. Embedded SQL in RPG is not generally considered to be 'native RPG I/O', and that helps keep SQL considerations in mind. RUNSQL should be thought of the same way.   Tom
    125,585 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