Applying SQL model statements
The following procedure combines an SQL model statement with a list of tables to generate SQL with host variables that adds the RESTRICT ON DROP attribute to a group of tables.
To apply SQL statements to lists
Create an SQL model statement in the Catalog Manager SQL_Table.For this example, create a member called RESTRICT, which contains two host variables, :CREATOR and :NAME. The host variables represent the Db2 catalog columns that contain the data to be substituted for the variables.
- Generate an object list. For information, see Generating-lists-in-Catalog-Manager.
- On the object list, in the Cmd column, type X beside objects that you want to exclude from processing and press Enter.
On the Command line, type APPLY memberName ALL and press Enter.In this example, the SQL_Table memberName is RESTRICT.
Catalog Manager displays the Confirm APPLY SQL MODEL panel, which contains the SQL model statement at the bottom of the panel .
DEFF-R ------------------- Confirm APPLY SQL MODEL -------------------------
Command ===>
Edit SQL Model . . . . . N (Y/N) Current SQLID : RDACRJ2
Replace with SQL Member .
Save model in SQL table . N (Y/N)
Apply to list objects . . N (Y/N)
Name of saved SQL . . . . RDACRJ2.RESTRICT
------------------------------------ SQL -----------------------------------
More: +
ALTER TABLE :CREATOR . :NAME ADD RESTRICT ON DROP;
******************************** BOTTOM OF DATA ******************************- In the Confirm APPLY SQL MODEL panel, you can edit and save the SQL, and apply the SQL to the objects in the list.
- In the Edit SQL Model field, type Y or N to edit the SQL and then press Enter.An ISPF edit panel is displayed, from which you can edit the SQL. Press END to return to the Confirm APPLY SQL MODEL panel.
- In the Replace with SQL Member field, type the name of another member to replace the existing member and then press Enter.
- In the Save model in SQL table field, type Y or N to save the SQL and then press Enter.
- In the Name of saved SQL field, specify the owner and name for the SQL and then press Enter.
In the Apply to list objects field, type Y or N to apply the SQL model statement to list objects that were not excluded and then press Enter.Catalog Manager displays the Confirm SQL panel (the following figure). Values from the Db2 catalog have been substituted for the host variables.
DEFF-R -------------------------- Confirm SQL ------------ Row 1 to 15 of 235
Command ===> Scroll ===> PAGE
Current SQLID. . . . . . . . MVSSXS2
Edit Options . . . . . . . . N Y/N Modify SQL processing options
Edit SQL . . . . . . . . . . N Y/N Edit SQL before executing
Save in SQL table. . . . . . N A/Y/R/N A/Y-Append, R-Replace
Name of saved data. . . . . 20220222_094815
Save in PDS. . . . . . . . . N Y/N Save in PDS
PDS(member) . . . . . . . . ACT.V12.DATABASE(TEST)
Execute SQL. . . . . . . . . N Remote Db2 . NONE Enter ? for list
------------------------------------ SQL ------------------------------------
ALTER TABLE QZU . QZUT01_DCI08S01
ADD RESTRICT ON DROP;
ALTER TABLE QZU . QZUT02_DCI08S01
ADD RESTRICT ON DROP;
ALTER TABLE QZU . QZUT03_DCI08S01
ADD RESTRICT ON DROP;
- On the Confirm SQL panel, you can edit and save the SQL and then execute it.
(Optional) From the Command line, issue the SET sqlid command to change the value of the current SQLID.
- (Optional) In the Edit options field, type Y to modify the default values for the options on the Confirm SQL panel and then press Enter.The Options panel is displayed. In the Edit SQL and Confirm options field, type Y to display the options for the Confirm SQL panel. Press END to return to the Confirm SQL panel.
- (Optional) In the Edit SQL field, type Y to invoke an ISPF edit session to edit the SQL statement and then press Enter.Press END to save the SQL and return to the Confirm SQL panel.
- (Optional) In the Save SQL field, type Y to save the SQL in the Catalog Manager SQL_Table. In the Name of saved SQL field, type a name for the SQL and then press Enter.The saved SQL uses the ID displayed in the Current SQLID field as the object qualifier. If the SQL is not saved, the ID in the Current SQLID is used only to identify Db2 authority.
(Optional) In the Remote Db2 field, perform one of the following steps to execute the SQL displayed on a different Db2 subsystem:
- Enter a Db2 subsystem ID.
- To select a Db2 subsystem from a list, type ? and then press Enter.
- (Optional) In the Execute field, type Y to execute the SQL displayed on the Confirm SQL panel and then press Enter.The SQL Progress Indicator panel is displayed. The panel automatically refreshes to display the status of the SQL that is being executed.