Tutorial: Editing and Executing IMS DDL
Goal
Create a DBD and PSB definition using IMS DDL statements and activate the changes in IMS from within an IMS project.
Prerequisites
- An IMS project exists in the IMS Projects view. If you have not created one, see Creating IMS Projects.
- An IMS database connection is configured in the IMS Connections view. If you have not created one, see Creating IMS Connections.
Part 1: Create and execute the DBD DDL
Steps
In the IMS Projects view, right-click your project and select New SQL File. Enter a name for the file (for example,
create-dbd).Add the following DBD DDL to the file. This example creates a database named
SAMPLEDBwith a tablespace and three segment tables. Adjust the names and sizes to match your design:DROP DATABASE SAMPLEDB; CREATE DATABASE SAMPLEDB ACCESS HDAM OSAM RMNAME(DFSHDC40 RMANCH 3 RMRBN 3 RMBYTES 25) CCSID 'Cp1047' VERSION '1.0'; CREATE TABLESPACE SAMPLETS IN SAMPLEDB SIZE PRIMARY 8192; CREATE TABLE ROOT_SEG ( KEY_COL CHAR(6) INTERNALNAME KEYVAL PRIMARY KEY, FIELD_1 CHAR(25) INTERNALNAME FLDONE, FIELD_2 CHAR(25) INTERNALNAME FLDTWO ) IN SAMPLEDB.SAMPLETS INTERNALNAME ROOTSG MAXBYTES 56; CREATE TABLE CHILD_SEG_A ( FIELD_3 CHAR(25) INTERNALNAME FLDA, FIELD_4 CHAR(25) INTERNALNAME FLDB, FIELD_5 CHAR(2) INTERNALNAME FLDC, FIELD_6 CHAR(9) INTERNALNAME FLDD, FOREIGN KEY REFERENCES ROOT_SEG ) IN SAMPLEDB.SAMPLETS INTERNALNAME CHLSGA MAXBYTES 61; CREATE TABLE CHILD_SEG_B ( KEY_COL_B INT INTERNALNAME KEYB PRIMARY KEY, FIELD_7 SHORT INTERNALNAME FLDE, FIELD_8 DECIMAL(9,2) INTERNALNAME FLDF, FOREIGN KEY REFERENCES ROOT_SEG ) IN SAMPLEDB.SAMPLETS INTERNALNAME CHLSGB MAXBYTES 15; COMMIT DDL;Important: All
CREATE DATABASE,CREATE TABLESPACE, andCREATE TABLEstatements for the DBD must be submitted together in a single execution, ending withCOMMIT DDL.At the top of the SQL file, click the IMS Connection CodeLens to select the IMS database connection to execute against.
Click the Execute button in the editor title bar. When prompted, confirm the IMS database connection.
Review the results in the results view to confirm that
COMMIT DDLcompleted without errors.
Part 2: Import the DBD definition
COMMIT DDL writes the DBD to the IMS catalog staging area but does not activate it in the running IMS system. The following steps activate the changes.
Steps
If you are making structural changes to an existing database, stop the database before importing. In the COMMAND folder of your IMS project, create a command file and issue:
/STOP DB SAMPLEDBSee Executing IMS Commands for details on running commands.
Issue the following type-2 command to import the staged definition and activate it in IMS:
IMPORT DEFN SOURCE(CATALOG)After the import completes, restart the database if you stopped it:
/START DB SAMPLEDBIn the IMS Connections view, right-click the connection and select Refresh. The new database should appear in the connection tree view.
Part 3: Create and execute the PSB DDL
After the DBD is committed and imported, define the PSB in a separate SQL file.
Steps
In the IMS Projects view, right-click your project and select New SQL File. Enter a name for the file (for example,
create-psb).Add the following PSB DDL to the file. This example creates a program view named
SAMPLEPGMthat accesses the database defined in Part 1:CREATE PROGRAMVIEW SAMPLEPGM ( CREATE SCHEMA PCB01 USING SAMPLEDB ( CREATE SENSEGVIEW ROOT_SEG, CREATE SENSEGVIEW CHILD_SEG_A, CREATE SENSEGVIEW CHILD_SEG_B ) PROCOPT 'A' POSMULT ) LANGCOBOL; COMMIT DDL;Important: All
CREATE PROGRAMVIEWandCREATE SCHEMAstatements for the PSB must be submitted together in a single execution, ending withCOMMIT DDL.Select the IMS Connection CodeLens at the top of the file and confirm the target connection.
Click Execute. Review the results view to confirm that
COMMIT DDLcompleted without errors.Issue
IMPORT DEFN SOURCE(CATALOG)again to activate the PSB definition, following the same steps as in Part 2.
Tips
- Use separate SQL files for the DBD and PSB DDL to keep each unit of work clearly scoped and easy to rerun.
- If a DDL execution fails, correct the statements and re-execute the entire file — all statements in the file are submitted as a single unit of work.
- After activating changes, refresh the IMS connection to confirm the definitions are visible in the connection tree view.
- A DBD created through DDL has only a logical definition. To allocate physical data sets for the database, use JCL on the mainframe or Zowe.