Ims Db 简明教程

IMS DB - Control Blocks

IMS 控制块定义 IMS 数据库的结构和程序对它们的访问权限。下图显示了 IMS 控制块的结构。

control block

DL/I 使用以下三种类型的控制块 −

  1. Database Descriptor (DBD)

  2. Program Specification Block (PSB)

  3. Access Control Block (ACB)

Database Descriptor (DBD)

重点注意事项:

  1. DBD 一旦定义了所有段,就描述了数据库的完整物理结构。

  2. 在安装 DL/I 数据库时,必须创建 DBD,因为需要访问 IMS 数据库。

  3. 应用程序可以使用 DBD 的不同视图。它们称为应用程序数据结构,它们在程序规范块中指定。

  4. 数据库管理员通过编码 DBDGEN 控制语句来创建 DBD。

DBDGEN

DBDGEN 是数据库描述符生成器。创建控制块是数据库管理员的责任。所有负载模块都存储在 IMS 库中。汇编语言宏语句用于创建控制块。下面提供了一个示例代码,演示如何使用 DBDGEN 控制语句创建 DBD −

PRINT	NOGEN
DBD	NAME=LIBRARY,ACCESS=HIDAM
DATASET	DD1=LIB,DEVICE=3380
SEGM	NAME=LIBSEG,PARENT=0,BYTES=10
FIELD	NAME=(LIBRARY,SEQ,U),BYTES=10,START=1,TYPE=C
SEGM	NAME=BOOKSEG,PARENT=LIBSEG,BYTES=5
FIELD	NAME=(BOOKS,SEQ,U),BYTES=10,START=1,TYPE=C
SEGM	NAME=MAGSEG,PARENT=LIBSEG,BYTES=9
FIELD	NAME=(MAGZINES,SEQ),BYTES=8,START=1,TYPE=C
DBDGEN
FINISH
END

让我们了解上述 DBDGEN 中使用的术语 −

  1. 当您在 JCL 中执行上述控制语句时,它创建一个物理结构,其中 LIBRARY 是根段,而 BOOKS 和 MAGZINES 是其子段。

  2. 第一个 DBD 宏语句标识数据库。在此,我们需要提及 DL/I 用于访问此数据库的 NAME 和 ACCESS。

  3. 第二个 DATASET 宏语句标识包含数据库的文件。

  4. 使用 SEGM 宏语句定义段类型。我们需要指定该段的 PARENT。如果它是根段,则提及 PARENT=0。

下表显示了 FIELD 宏语句中使用的参数 −

S.No

Parameter & Description

1

Name 字段名称,通常为 1 到 8 个字符长

2

Bytes Length of the field

3

Start 段内字段的位置

4

Type 字段的数据类型

5

Type C Character data type

6

Type P 打包十进制数据类型

7

Type Z 带区十进制数据类型

8

Type X Hexadecimal data type

9

Type H 半字二进制数据类型

10

Type F 整字二进制数据类型

Program Specification Block (PSB)

PSB 的基础知识如下所述 −

  1. 数据库有一个由 DBD 定义的单一物理结构,但处理它的应用程序可以有不同的数据库视图。这些视图称为应用程序数据结构,并且在 PSB 中定义。

  2. 没有哪个程序可以在单次执行中使用多个 PSB。

  3. 应用程序有自己的 PSB,对于具有相似数据库处理要求的应用程序共享 PSB 来说是常见的。

  4. PSB 由一个或多个称为程序通信块 (PCB) 的控制块组成。PSB 为应用程序程序将访问的每个 DL/I 数据库包含一个 PCB。我们将在后续模块中详细讨论 PCB。

  5. 必须执行 PSBGEN 才能为程序创建 PSB。

PSBGEN

PSBGEN 被称为程序规范块生成器。以下示例使用 PSBGEN 创建 PSB −

PRINT   NOGEN
PCB     TYPE=DB,DBDNAME=LIBRARY,KEYLEN=10,PROCOPT=LS
SENSEG  NAME=LIBSEG
SENSEG  NAME=BOOKSEG,PARENT=LIBSEG
SENSEG  NAME=MAGSEG,PARENT=LIBSEG
PSBGEN  PSBNAME=LIBPSB,LANG=COBOL
END

让我们了解上述 DBDGEN 中使用的术语 −

  1. The first macro statement is the Program Communication Block (PCB) that describes the database Type, Name, Key-Length, and Processing Option.

  2. DBDNAME parameter on the PCB macro specifies the name of the DBD. KEYLEN specifies the length of the longest concatenated key. The program can process in the database. PROCOPT parameter specifies the program’s processing options. For example, LS means only LOAD Operations.

  3. SENSEG is known as Segment Level Sensitivity. It defines the program’s access to parts of the database and it is identified at the segment level. The program has access to all the fields within the segments to which it is sensitive. A program can also have field-level sensitivity. In this, we define a segment name and the parent name of the segment.

  4. The last macro statement is PCBGEN. PSBGEN is the last statement telling there are no more statements to process. PSBNAME defines the name given to the output PSB module. The LANG parameter specifies the language in which the application program is written, e.g., COBOL.

Access Control Block (ACB)

Listed below are the points to note about access control blocks −

  1. Access Control Blocks for an application program combines the Database Descriptor and the Program Specification Block into an executable form.

  2. ACBGEN is known as Access Control Blocks Generator. It is used to generate ACBs.

  3. For online programs, we need to pre-build ACBs. Hence the ACBGEN utility is executed before executing the application program.

  4. For batch programs, ACBs can be generated at execution time too.