Previous Topic: Define and Delete Fields in an NDB

Next Topic: EASINET Considerations

Access an NDB

Before any records can be added to, deleted from, or retrieved from an NDB, the NCL process must sign on, or connect itself to the NDB. This is accomplished using the &NDBOPEN verb:

&NDBOPEN dbname

This statement registers the NCL process as a signed-on user of the nominated NDB.

If you want the NCL process to have exclusive control over the NDB, then specify the keyword, EXCLUSIVE, after the database name.

If you want to perform input only operations, then use the INPUT keyword.

If a security exit is being used, the DATA keyword can be used to allow up to 50 characters of data to be passed to the exit.

The &NDBRC system variable should always be checked after &NDBOPEN, to ensure it was successful. If the value of &NDBRC is not 0, then the open has failed, except for response 34, which indicates that the NCL process is already signed on.

When an &NDBOPEN is executed, &NDBCTL ERROR=CONTINUE is always assumed, to allow the NCL process to handle errors at this point. If an open failure occurs, and no action is taken, then the next &NDBxxx statement for that database will get a not open response. Response 34 (already open) will terminate the procedure unless an explicit &NDBCTL ERROR=CONTINUE is in effect.

The &NDBOPEN verb is analogous to the &FILE OPEN verb. However, there is no need to reissue &NDBOPEN after referencing an NDB of another name. This is because &NDB statements that refer to an NDB require the name of the NDB that is to be accessed, whereas the &FILE verbs assume the UDB named in the last executed &FILE OPEN statement.