Adabas Writing Considerations

In this section:

The Adapter for Adabas is designed to support SQL update commands for an Adabas data source without the use of remote procedures. These topics describe the methods and rules related to write capability.


Top of page

x
Adabas Write Adapter

Before you can use any commands that write to an Adabas data source, you must make the following changes to the Master and Access Files:

In the Master File:

In the Access File:

When using the Write Adapter for Adabas, the adapter automatically sets the values of the following two options:


Top of page

x
SQL Commands for the Adapter for Adabas

How to:

Reference:

The Adapter for Adabas supports the following commands:

The adapter issues a COMMIT after each INSERT, UPDATE, or DELETE call. If the Adabas process fails, the adapter issues a ROLLBACK. User rollback of the Adabas process is not supported for SQL commands.



x
Reference: Obtain Counts of Rows Updated or Deleted

While processing SQL transactions, you can issue the PASSRECS command to obtain counts of rows affected by each successfully executed SQL Passthru INSERT, UPDATE, or DELETE command.



x
Syntax: How to Count Records Updated, Inserted or Deleted

ENGINE ADBSINX INT SET PASSRECS {ON|OFF}

where:

ADBSINX

Indicates the adapter. You can omit this value if you previously issued the SET SQLENGINE command.

INT

Indicates that the PASSRECS setting in this command will be applied globally to all adapters that support SQL INSERT, UPDATE, and DELETE commands.

ON

Provides the number of rows affected in the application program SCB count member after the successful execution of an SQL Passthru INSERT, UPDATE, or DELETE command. ON is the default value.

OFF

Provides no information after the successful execution of an SQL Passthru INSERT, UPDATE, or DELETE command.

In addition, the adapter updates the &RECORDS system variable with the number of rows affected. You can access this variable using Dialogue Manager.



x
Reference: Fields That Cannot be Updated

The SQL UPDATE command for the following types of fields is ignored:

The SQL UPDATE command for the following types of fields produces an error:



x
Reference: Using Synonym Fields (Not Related to Creating a Synonym)

In a Master File, two or more field declarations can refer to the same Adabas field. Each duplicate field declaration after the first is called a synonym field. Such synonym fields can be used in report commands, but cannot be used in write commands. The following actions occur as a result of using synonyms in write commands:



x
Syntax: How to Insert Records Into an Adabas Data Source
INSERT INTO mfname [(field1, field2, ...)]
VALUES ('value1','value2', ...)

where:

mfname

Is the name of the Master File to use.

field1, field2, ....

Is an optional list of fields to be inserted. If you omit the list, the value list must contain values for all fields in all segments in the Master File as long as the Master File only specifies a single path Adabas file. If the Master File is multi-path, the field list is required and can specify only a single path. Elementary fields not included in the field list have empty values in the data source. The field list can contain only elementary fields. Groups, subdescriptors, superdescriptors, and hyperdescriptors, cannot be used in the field list.

'value1', 'value2', ...

Is the list of values to be inserted. Each alphanumeric value must be enclosed in single quotation marks. If you specify the field name list, the value list only needs to specify, in field name list order, the values for the field names supplied. At a minimum, you must supply all the key fields for all the segments in the path to the target.

If a segment is not present, default values are generated for all fields that are not supplied, and the missing path segments are inserted along with the target segment.



x
Reference: Rules for Inserting Records Into an Adabas Data Source


x
Reference: Effect of UNQKEYNAME on INSERT Actions

The UNQKEYNAME attribute in the Access File determines how the adapter presents an INSERT command to Adabas. The UQ option in the ADABAS FDT and the specific field values listed in the INSERT command determine whether Adabas actually inserts the segment instance. The following table describes how these factors affect the result of the INSERT command. Assume that the Access File specifies UNQKEYNAME=EMPLOYEE_ID and that the employee ID value EMPID005 already exists in the data source:

Result of the INSERT Command for Existing EMPLOYEE_ID EDMPID005

EMPLOYEE_ID has the UQ Option in FDT

Fields in INSERT Command

Instance Inserted

No

EMPLOYEE_ID only.

No - rejected duplicate

Yes

EMPLOYEE_ID only.

No - rejected duplicate

No

EMPLOYEE_ID plus fields with values that do not already exist.

Yes

Yes

EMPLOYEE_ID plus fields with values that do not already exist.

No - message (FOC4561), RC=198

Result of INSERT Command when EMPLOYEE_ID is not in the field list

UNQKEYNAME = EMPLOYEE_ID

Instance Inserted

Yes

No - message (FOC4563)

No

Yes, with empty EMPLOYEE_ID value.



x
Syntax: How to Update Field Values in an Adabas Data Source
UPDATE mfname SET field1 ='value1' [,field2 ='value2'...]
WHERE kfield1 ='kvalue1' [AND kfield2 ='kvalue2'...]

where:

mfname

Is the name of the Master File to use.

field1, field2, ...

Are the names of the fields to be updated.

'value1', 'value2', ...

Are the new values for the updated fields, enclosed in single quotation marks.

kfield1, kfield2, ...

Are, at a minimum, all of the key fields for all the segments in the path to the target. Only one target segment is updated. You can include additional fieldname=value pairs for the target or any segment in the path. When additional fieldname=value pairs are present for the target segment, these are used for change verification protocol processing. If all target fieldname=value pairs that are present match the Adabas segment field values, the segment is updated with the SET fieldname values. The field list can contain only elementary fields. Groups, subdescriptors, superdescriptors, and hyperdescriptors, cannot be used in the field list.

'kvalue1', 'kvalue2', ...

Are the values that identify the target segment, enclosed in single quotation marks.



x
Reference: Rules for Updating Records in an Adabas Data Source


x
Syntax: How to Delete Records From an Adabas Data Source
DELETE FROM mfname WHERE field1 ='value1' [AND field2 ='value2'...]

where:

mfname

Is the name of the Master File to use.

field1, field2, ...

Are, at a minimum, the names of all of the key fields for all the segments in the path to the target. Only one target segment is deleted; Adabas cascades the delete to dependent segments. Additional fieldname=value pairs may be included for the target segment and any segment in the path that has no key or a non-unique key. It is recommended to use Adabas descriptor fields for any additional fieldname=value pairs.

'value1', 'value2', ...

Are the values that identify the target segment to be deleted.



x
Reference: Rules for Deleting Records From an Adabas Data Source

iWay Software