SQL

FUNCTION

To introduce SQL UPDATE or DELETE commands directly into the generated program.  This statement has been introduced into Jazz to facilitate

FORMAT

SQL UPDATE Table

SET Column = Value [,Column = Value]…

{WHERE Condition | ALLROWS};

Or

            SQL DELETE Table

              {WHERE Condition | ALLROWS};

Or    SQL {COMMIT | ROLLBACK};

Rules

Table is the name of a “file” with FileType SQL.   This must be defined in the Jazz program.

SET defines one or several assignments, separated by commas.   Each assignment has the form

            Column = Value

            Column is a field name defined within Table

            Value may either be a constant, or a field that is not defined within Table

WHERE defines a condition for the rows that will be updated or deleted.  This option is compulsory unless you’ve written ALLROWS.   Jazz does not insert ALLROWS if WHERE is missing, but you can edit the UPDATE or DELETE condition to add it to show that you really intended every row in the table to be updated or deleted.  

FUNCTION

SQL UPDATE will update the selected rows with the values given in the SET option.

SQL DELETE will delete the selected rows

SQL COMMIT immediately ensures that all changes that have been made to the database are committed, so they will be available to other users even if your program later abends.

SQL ROLLBACK rolls back all changes to the database since the previous commit.

 

Note that Jazz does not provide

            SQL SELECT

Instead, if you want to process several rows, write something like: -

            PROCESS Table WHERE condition UPDATE

                        Program logic that may change the values of one or more columns

            END PROCESS Table UPDATE;

See https://www.jazzsoftware.co.nz/Docs/JazzLRM_PROCESS.htm for more information.

 

To do this for a single row, use similar code with GET instead of PROCESS.  See https://www.jazzsoftware.co.nz/Docs/JazzLRM_GET.htm

 

Note: if your program contains PROCESS or GET statements that update SQL tables, the generated COBOL logic will execute a COMMIT when the program ends normally, and ROLLBACK if the program ends abnormally.