HPlogo Communicator 3000 MPE/iX Release 6.5 (Non-Platform Software Release C.65.00) > Chapter 5 Internet and Interoperability

Transact/iX Expanded B-Tree and File Open Enhancement

MPE documents

Complete PDF
Table of Contents
Index

by James Overman
Commercial Systems Division

Hewlett-Packard has implemented two more enhancements in Transact/iX (HP30138A.07.00). They are:
  • Expanded support of TurboIMAGE B-tree

  • Ability to pass database and file ids to Transact/iX

Support of B-Trees in Transact


With the release of IMAGE/SQL that provided TurboIMAGE B-trees, Transact/iX supported a portion of that feature. The Simple Argument structure of DBFIND was supported requiring no modifications to the Transact language. A FIND for X or U type items having B-tree indices and with the BTREEMODE1 option ON performs index searching with a wildcard character. Here's an example. First, assume the BTREEMODE1 option is set ON for this database. Also, B-tree indices have been created for the key item of the master data set allowing for indexed retrievals. See the TurboIMAGE Reference Manual if you are not familiar with B-tree indexing.

In Transact, the source code would look like the following:

  MOVE (NAME) = "Sm@";
  SET(KEY) LIST(NAME);
  OUTPUT(CHAIN) PEOPLE, LIST=(NAME);

This program would display all names in the detail data set, PEOPLE, which begin with "Sm".
  • Smalley

  • Smith

  • Smythe

The full capability of B-trees required more functionality to be added to Transact/iX. HP has expanded upon the Simple Argument DBFIND by allowing other DBFIND modes to be specified. By allowing the DBFIND mode and the argument (structured or simple) to be specified, Transact/iX supports the full capability of TurboIMAGE B-trees.

The Structured Argument can be specified by the SET(KEY) and LIST(KEY) statements. The SET(KEY) sets both the argument and key registers to the search argument item. The LIST(KEY) statement resets the key register to the search or key item. The Structured Argument item can be constructed via parent/child items or with simple items using string functions and concatenation.

Transact/iX has an added FINDMODE option on DELETE, FIND, GET, OUTPUT, REPLACE, and PATH statements. The syntax looks like:

  FIND(CHAIN) dataset, LIST=(item1:item3), FINDMODE=4;

The B-tree search can only be used for the following data retrieval verbs: DELETE, FIND, GET, OUTPUT, REPLACE, and PATH. Only the CHAIN or RCHAIN modifiers can be used for the data retrieval verbs. The key and argument register should be set prior to the data retrieval. The STATUS count returned may not always be accurate. For example, DBFIND modes 21 and 24 do not return the correct chain count or entry numbers.

The complete syntax for the FIND verb is shown below.

Syntax


  FIND [(modifier)] file-name [,option-list];

Parameters

Option-list

One or more of the following options, separated by commas. Only the additional option is listed here. See the Transact/iX Reference Manual for all the other possible options.

FINDMODE=mode

Only available with the CHAIN or RCHAIN modifiers. Performs optimized searching of an index by using TurboIMAGE/XL's B-tree index functionality or Third Party Indexing. The mode is the mode that is specified for the DBFIND of this data retrieval verb. If the FINDMODE option is not specified, DBFIND mode 1 is used.

Here are some examples of B-tree Structured Arguments in Transact/iX. Assume BTREEMODE1 is ON and B-tree indices exist.

Example 1


  system ex1,base=passks;
  define(item) search-arg      x(30):
               search-type     x(2)=search-arg(1):
               search-version  I(5,,2)=search-arg(3):
               arg1-size       I(5,,2)=search-arg(5):
               arg2-size       I(5,,2)=search-arg(7):
               arg1            x(8)=search-arg(9):
               arg2            x(8)=search-arg(17):
               prod-no         x(8):
               ship-date       x(6);

  list search-arg,init:
       prod-no:
       ship-date;

  << Retrieve all product numbers beginning with PROD. >>
  << Uses DBFIND mode 1.  >>

  move (prod-no) = "PROD@";
  set(key) list(prod-no);
  output(chain) inventory, list=(prod-no:ship-date);

  << Retrieve all product numbers between PROD1 and PROD2.  >>
  << Uses DBFIND mode 4. >>
  << Uses parent/child items to devise Structured Argument. >>

  move (search-type) = "[]";
  let (search-version) = 0;
  let (arg1-size) = 8;
  let (arg2-size) = 8;
  move (arg1) = "PROD1   ";<< Blank pad the full number of >>
  move (arg2) = "PROD2   ";<<   characters.>>

  set(key) list(search-arg);
  list(key) prod-no;
  output(chain) inventory, list=(prod-no:ship-date),findmode=4;
  exit;

Example 2


  system ex2, base=passks;

  define(item) search-arg      x(30):
               search-version  I(5,,2):
               arg1-size       I(5,,2):
               arg2-size       I(5,,2):
               arg2            x(8):
               prod-no         x(8):
               ship-date       x(6);

  list search-arg,init:
       search-version,init:  << 0 >>
       arg1-size,init:
       arg2-size,init:
       arg2,init:
       prod-no:
       ship-date;

 << Use items and functions to concatenate the Structured Argument.>>
 << Use DBFIND mode 24.  >>
 << Same output as the second part of Example 1.  >>

  << search-version set to 0 during list statement >>
  let (arg1-size) = 8;
  let (arg2-size) = 8;
  move (arg2) = "PROD2   "; << Blank pad. >>

  move (search-arg) = "[]" + (search-version) + (arg1-size) +
                     (arg2-size) + col("PROD1",9) + col((arg2),17);

  set(key) list(search-arg);
  list(key) prod-no;
  output(chain) inventory, list=(prod-no:ship-date),findmode=24;

  << Another way to setup the Structured Argument.    >>
  << Same results as above.  >>

  list search-arg,init;
  move (search-arg) = col("[]",1);
  move (search-arg) = col((search-version),3);
  move (search-arg) = col((arg1-size),5);
  move (search-arg) = col((arg2-size),7);
  move (search-arg) = col("PROD1",9);
  move (search-arg) = col("PROD2",17);

  set(key) list(search-arg);
  list(key) prod-no;
  output(chain) inventory, list=(prod-no:ship-date),findmode=24;
  exit;

File Open Transact


"File Open" is the name of the feature which allows database and file ids to be passed into Transact/iX from other languages or Third Party packages. This allows the Transact program to use the same databases and files used by the calling program. The Ids are shared so both programs can share current record numbers, entries, paths, etc. This feature requires a call to TL_CALL_TRANSACT (aka Transact/iX ACI) from another language or package. HP has also included an additional enhancement, the ability to defer the database open.

These enhancements required changes to two Transact/iX statements, SYSTEM and LIST.

SYSTEM Statement

The SYSTEM statement needs to tell Transact/iX if the database or file id is being passed. The new syntax is shown below.
Syntax

  SYSTEM program-name [,definition-list];

Parameters
Definition-list

Description of the files or data sets used during execution. See the Transact Reference Manual for other definitions.


  BASE=base-name[(["password"][,[mode][,[optlock][,[basetype]
    [,[open-type]]]]])].

open-type

Used by Transact/iX to determine when and if to open the database. The valid types are OPEN, DEFER, PASSED. OPEN is the default and opens the database at the beginning of the Transact/iX program. DEFER delays the database open until the database is first accessed. PASSED tells Transact/iX not to open the database - the database id is being passed from another program.


  FILE=file-name[([access][(file-option-list)] [,[record-length]
    [,[blocking-factor] [,[file-size][,[extents]
    [,[initial-allocation][,[file-code]]]]]]])].

file-option-list

Any of the following fields provided that they do not conflict in meaning: OLD, NEW, TEMP, $STDLIST, $NEWPASS, $OLDPASS, $STDIN, $STDINX, $NULL, ASCII, CCTL, SHARE, LOCK, NOFILE, HP3000_16, HP3000_32, DEFER, PASSED.

Either DEFER or PASSED can be specified. DEFER opens the file when the file is first used in a Transact/iX program. PASSED does not open the file - generally the file id is passed from another program. If neither DEFER or PASSED is specified, then DEFER is assumed. DEFER is the way Transact/iX worked prior to this enhancement.


  KSAM= file-name[(access)[(file-option-list)]].

See FILE= for DEFER and PASSED options.

LIST Statement

The next statement that Transact/iX needed to enhance is the LIST statement. The new syntax is shown below.
Syntax

  LIST item-name[,option-list]; << Adds the item-name to the list >>
                                << register.>>

Parameters
Option-list

Specifies a value to be placed in the data register. For current options, refer to the Transact Reference Manual.

BASEID[(base-name)]

An X(2) item that contains the database id passed from a main program assigned to a database by TurboIMAGE's DBOPEN. If no base-name is specified, then the home base is assumed. Note, the home base cannot be specified.

FILEID(file-name)

A 16-bit integer (I(5,,2)) containing the file identifier assigned to a file by MPE's FOPEN.

The database/file on the SYSTEM statement should have the PASSED option or an error will occur. Any database/file name in the SYSTEM statement can actually be a different named database/file. There is not a check to verify that the database/file names are actually the same.

For example, if the calling program opened a database named PEOPLE, then Transact/iX assigns that database id to its database name of EMPLOYEES (structured the same as PEOPLE):

  LIST people-id,BASEID(employees);

Example: Pascal Code - Main Program

Here is an example using Pascal to call Transact/iX.

     .
     .
     .
     type
       data_record = packed record
          x_type   : packed array[1..8] of char;
          id_type  : packed array[1..2] of char;
          filler   : packed array[1..48] of char;
        end;
     .
     .
     .
     var
       data_buffer : data_record;
     .
     .
     .
     base_name := '  NAME; ';
     password  := 'PASS1 ';
     mode := 1;
     dbopen (base_name, password, mode, db_status_array);
     { check db_status_array }
     .
     .
     .
     strmove (2, base_name, 1, data_buffer.id_type, 1);

     system_name := 'aci01   ';
     data_size  := 58;
     tl_call_transact (system_name, addr(data_buffer),
                       data_size, return_status);
     { check Transact's return_status }
     .
     .
     .
     end.

Example: Transact Code - Subprogram


 << This code is compiled and added to the XL. >>

  system aci01,base=name(,1,,PASSED);
  << NAME database is not opened by Transact/iX. >>

  define(item) x-item       x(8):
               name-id      x(2):
               name         x(8):
               address      x(32):
               phone        x(8);

  list     x-item:
           name-id,BASEID:   << Home base assumed. >>
           name, init:
           address,init:
           phone,init;

  << Use database ID from Pascal code to perform retrieval.  >>

  output(serial) employees, list=(name:phone);
  exit




XM User Checkpoint Priority Control


Apache for MPE/iX 6.5