Previous Topic: &NDBDEF

Next Topic: &NDBFMT


&NDBDEL

Deletes a record from an NDB database.

&NDBDEL dbname RID=n

The &NDBDEL statement allows an NCL procedure to delete a record from an NDB. The record to be deleted is identified by a record-ID (RID). This record ID is assigned to each record when it is added to the database by &NDBADD, and never changes. The system variable, &NDBRID, is set by several &NDB statements to indicate the RID of the current record.

Operands:

dbname

The name of the NDB that you wish to delete the record from is a required operand. This NDB must have been previously opened by an &NDBOPEN statement.

RID=n

This required operand is used to indicate the RID of the record to delete. n is the record ID, which is inserted by substitution, typically using &NDBRID, which has been set by, for example, a preceding &NDBGET statement.

Examples: &NDBDEL

&NDBGET MYNDB FIELD=SURNAME VALUE='BLOGGS' FORMAT + 
 NO-FIELDS 
&NDBDEL MYNDB RID=&NDBRID

This example uses &NDBGET to retrieve a record with field SURNAME equal to BLOGGS, and then will delete it.

&NDBSEQ MYNDB DEFINE SEQ=S1 FIELD=SUBURB VALUE=BRONX
&NDBGET MYNDB SEQ=S1 FORMAT NO-FIELDS
&DOWHILE &NDBRC = 0
   &NDBDEL MYNDB RID=&NDBRID
   &NDBGET MYNDB SEQ=S1 FORMAT NO-FIELDS
&DOEND

This example deletes all records (if any) in NDB MYNDB with field SUBURB equal to BRONX.

Notes:

Errors encountered whilst processing the &NDBDEL statement could cause the procedure to terminate, or may just be reflected in the &NDBRC system variable, depending on the setting of &NDBCTL ERROR option.

A successful delete sets &NDBRC to 0. If the RID does not exist in the database, &NDBRC is set to 1.

More information:

&NDBADD

&NDBGET

&NDBUPD