Using KSAM/XL and KSAM 64 (32650-90886)

Appendix B 235
BASIC/V Intrinsics
BKDELETE
When access is shared, the call that positions the pointer to the record to be deleted should
be included in the same pair of BKLOCK/BKUNLOCK calls as the call to BKDELETE. This
ensures that no other user alters the record position between the call that locates the
record and the call that deletes it.
Figure B-2. contains an example illustrating the logical deletion of a record from a KSAM
file.
Figure B-2. Deleting a Record With BKDELETE
3240 REM ******************************************************
3250 REM * REMOVE A RECORD FROM A KSAM FILE *
3260 REM ******************************************************
3270 REM
3280 REM F IS THE FILE NUMBER OF A KSAM FILE OPENED BY A CALL TO BKOPEN
3290 REM NOTE THAT FOR BKDELETE, BKOPEN ACCESS MODE MUST = 4 FOR UPDATE
3295 REM
3300 REM THE RECORD TO BE DELETED MUST FIRST BE READ...
3305 REM AN ASSUMPTION HAS BEEN MADE THAT THE RECORD TO BE READ
3310 REM AND DELETED CONTAINS THE SAME INFORMATION THAT WAS
3320 REM WRITTEN IN THE BKWRITE EXAMPLE.
3330 REM
3340 CALL BKREAD(F,S$,B1$,B2$,A5[*],A3[*],A2[*])
3350 REM
3360 REM NOW DETERMINE WHETHER THE CALL WAS SUCCESSFUL
3370 REM
3380 IF S$[1;1]<>"0" THEN DO
3390 REM N$ CONTAINS THE NAME OF THE KSAM FILE
3400 REM S$ CONTAINS THE STATUS CODE SET BY THE PRECEDING CALL
3410 PRINT "UNABLE TO READ ";N$" ERROR ";S$[1;1];" DETAIL ";S$[2]
3420 CALL BKERROR(S$,M$)
3430 PRINT M$
3435 GOTO 3620
3440 DOEND
3450 REM
3460 CALL BKDELETE(F,S$)
3470 REM
3480 REM NOW DETERMINE WHETHER THIS CALL SUCCEEDED
3490 REM
3500 IF S$[1;1]<>"0" THEN DO
3510 REM N$ CONTAINS THE NAME OF THE KSAM FILE
3520 REM S$ CONTAINS THE STATUS CODE SET BY THE PRECEDING CALL
3530 PRINT "UNABLE TO DELETE RECORD FROM ";N$;
3535 PRINT "ERROR ";S$[1;1];"DETAIL ";S$[2]
3540 CALL BKERROR(S$,M$)
3550 PRINT M$
3560 GOTO 3620
3570 DOEND
3575 PRINT "DELETED RECORD CONTAINS ";B1$;B2$;
3576 MAT PRINT A5
3577 MAT PRINT A3,A2
3580 REM
3590 REM THE PROGRAM CONTINUES