Updating rows in sql

Rated 3.89/5 based on 663 customer reviews

In these type of situations, it is ideal to use a Update Cursor, than using the default read only one.Consider the following table: Here is how you use the Update Cursor.One question I have been asked by several people is how to update a row from a file that had been previously Fetched, just like READ and UPDATE using RPG's native database access.I thought it would be useful to show examples using both RPG native database access and SQL.I will be using the data structure to receive the input from the SQL Fetch.

updating rows in sql-42

updating rows in sql-63

Line 7: As this is a test program I want to be able to run this multiple times to make sure I update the right field with the right value.

Line 8: If I had defined TESTFILE without the user open the file would have been opened at program initialization, and the Copy File command would have failed.

By using the user open in the file's definition the file remains close until I open it. Line 9: This operation shows that I don't have to use a variable for the key field. Lines 10 – 17: My Do loop to read all of the records in the file.

As I had defined QCMDEXC as a external procedure previously I can call it as I would a procedure.

Rather than using variables to pass the Copy File command to the API I am using strings for both parameters.

Leave a Reply