FUNCTION DEL_DETAIL, DATE_OBS, ERRMSG=ERRMSG
;
    ON_ERROR, 2
;
;  Initialize RESULT to represent non-success.  If the routine is successful,
;  this value will be updated below.
;
    RESULT = 0
;
;  Check the number of parameters.
;
        IF N_PARAMS() NE 1 THEN BEGIN
           MESSAGE = 'Syntax:  DEL_DETAIL, DATE_OBS'
       GOTO, HANDLE_ERROR
        ENDIF
;
;  Make sure that the user has privilege to write into the database.
;
    IF !PRIV LT 2 THEN BEGIN $
           MESSAGE = '!PRIV must be 2 or greater to write into the database'
           GOTO, HANDLE_ERROR
    ENDIF
;
;  Check the input parameter.
;
    IF DATATYPE(DATE_OBS,1) NE 'Double' THEN BEGIN
           MESSAGE = 'DATE_OBS must be double precision'
           GOTO, HANDLE_ERROR
    END ELSE IF N_ELEMENTS(DATE_OBS) NE 1 THEN BEGIN
           MESSAGE = 'DATE_OBS must be a scalar'
           GOTO, HANDLE_ERROR
    ENDIF
;
;  Open the database for update.
;
    DBOPEN, 'sci_details', 1
;
;  Search for the entry with the start date/time given by the user.
;
    ENTRIES = DBFIND('DATE_OBS=' + TRIM(DATE_OBS,'(F15.3)') +   $
        ',DELETED=N', /SILENT)
;
;  If no entries were found, then return immediately.
;
    IF !ERR EQ 0 THEN BEGIN
           MESSAGE = 'No such entry in the database'
           GOTO, HANDLE_ERROR
    ENDIF
;
;  Delete the entry.
;
    DBUPDATE, ENTRIES, 'deleted', 'Y'
;
;  Open the pointing database and delete any associated entries.
;
    DBOPEN, 'point_details', 1
    ENTRIES = DBFIND('DATE_OBS=' + TRIM(DATE_OBS,'(F15.3)') +   $
        ',DELETED=N', /SILENT)
    IF !ERR GT 0 THEN DBUPDATE, ENTRIES, 'deleted',     $
        REPLICATE('Y',N_ELEMENTS(ENTRIES))
;
;  Signal success.
;
    RESULT = 1
    GOTO, FINISH
;
;  Error handling point.
;
HANDLE_ERROR:
    IF N_ELEMENTS(ERRMSG) NE 0 THEN ERRMSG = 'DEL_DETAIL: ' + MESSAGE $
        ELSE MESSAGE, MESSAGE, /CONTINUE
;
;  Close the database, and return.
;
FINISH:
    DBCLOSE
;
    RETURN, RESULT
    END