Section 12b
Stored Procedures — Ship Lifecycle  ·  SQL Server  ·  2026-05-03

12b Stored Procedures — Ship Lifecycle

SPs that manage the complete lifecycle of a vessel record: creation (62 table inserts in 7 transactions), deletion, status transitions, newbuild NCON date roll-forward, and casualty record management.

Lifecycle Stages

StagePrimary SPKey Tables Affected
CreationspCreateNewShipWithStatus62 ABSD_* tables + SUPPLEMENTAL_* entries
Confidential newbuildspCreateNewShipWithNCON_CONFISame as above + ABSD_NCON confi flag
Pre-load creationspPreLoadNewShipWithStatusASubset of tables, marked pre-load
Status changespUpdateShipStatus / spUpdateShipWithStatusABSD_HIST triggers cascade
Salvage/split statusspStatusChangeToSSABSD_HIST + ABSD_OVNA + ABSD_OVCA
Newbuild date advancespNEWCONDateRollForwardPhase1/2/3SUPPLEMENTAL_ABSD_NCON date fields
Casualty creationspCreateNewCasualty / spMakeNewCasABSD_CAGE1 + ABSD_OVCA re-sequence
DeletionspDeleteShipAll 62+ tables cleaned up

Vessel Lock Mechanism

All creation and deletion SPs use tblVesselLock to prevent concurrent edits. The table has one row: (Username, LockTime). A lock older than 5 minutes is auto-expired.

-- At start of create/delete:
DELETE tblVesselLock WHERE DATEDIFF(minute, Locktime, GetDate()) > 5
IF (SELECT COUNT(*) FROM tblVesselLock) = 0
BEGIN
    INSERT INTO tblVesselLock (Username, LockTime) VALUES (@Initials, GetDate())
    -- ... perform work ...
    DELETE tblVesselLock WHERE Username = @Initials
END
ELSE
    RAISERROR('Unable to create — deadlock would occur. Try again in a few minutes.', 16, 1)
Single-user lock: Only one vessel can be created or deleted at a time system-wide. This prevents partial-state corruption since the create SP spans 7 separate transactions with WAITFOR DELAY '000:00:02' between each to allow triggers to fire.

spCreateNewShipWithStatus — Full Vessel Creation

spCreateNewShipWithStatus @PASSEDLRNO varchar(7), @PASSEDEFD varchar(8), @PASSEDNAME varchar(50)='NAME TO BE OVERWRITTEN', @PASSEDINTBASIC varchar(5)='19000', @PASSEDTYPA varchar(3)='990' [... 25 more optional params]

Creates a complete, immediately valid vessel record across 62 tables in 7 sequential transactions. The comment at the top of the SP states: "Changes made to this procedure NEED to be made to spPreLoadNewShipWithStatusA and spCreateNewShipWithNCON_CONFI."

Key Parameters

ParameterDefaultMeaning
@PASSEDLRNORequired7-char LR number (also the IMO number)
@PASSEDEFDRequiredYYYYMMDD effective date for all initial records
@PASSEDNAME'NAME TO BE OVERWRITTEN'Initial vessel name — updated via ABSD_OVNA trigger
@PASSEDINTBASIC'19000'International Basic type code (ABSD_OVTY)
@PASSEDOWNER'9991001'Owner OWCODE — '9991001' = "Unknown/Unregistered"
@PASSEDBUILDER'UNK000015'Builder OWCODE
@PASSEDFLAG'UNK'ISO3 flag state
@PASSEDSTATUSNULLInitial A02_STS code (ABSD_HIST)
@STAT5CODE'B35X2XX'LR Stat5 type code (SUPPLEMENTAL_ABSD_OVTY)
@HULL_SHAPE'N1'Hull shape code (SUPPLEMENTAL_ABSD_OVTY)

Transaction Sequence (7 transactions)

Post-creation Integrity Check (62 tables verified)

After all 7 transactions, the SP tests existence of every inserted row. If any table is missing a row, @RETERR = 1 and EXEC spDeleteShip @PASSEDLRNO is called to clean up the partial record.

ABSD_SHIP_SEARCHABSD_OVGESUPP_OVGEABSD_OVNAABSD_HIFLSUPP_HIFLABSD_OVTYSUPP_OVTYABSD_OVCAABSD_FTMEABSD_FTNTABSD_FTQYABSD_FUCA1/2ABSD_FUCO1/2ABSD_FUDI1/2/3/4SUPP_FUDI1ABSD_FUDO1/2ABSD_FUGESUPP_FUGEABSD_FUHA1/2ABSD_FULCABSD_FULI1/2/3ABSD_FURO1/2ABSD_FUSFABSD_FUST1/2ABSD_FUTOABSD_FUUN1SUPP_FUUN1ABSD_HIBRABSD_HIDEABSD_HIDRABSD_HIFC1SUPP_HIFC1ABSD_HIFC2ABSD_FOR_CLASSABSD_HIGEABSD_HILCABSD_HILEABSD_HIMOABSD_HIMTABSD_HIOWABSD_HIPPABSD_HIMAABSD_HISMABSD_HIOPABSD_HIPP_DATEDABSD_HIGBOABSD_HITPABSD_HIPRABSD_HISEABSD_HISTABSD_HITLSUPP_HITLABSD_HITMABSD_HITSABSD_HITTABSD_LREQ1/2/3/4ABSD_LRGE/HI/HN/SC/SU/WDABSD_MAAU/BO/BU/EM1/EM2/EM3/GR/PR/SP/STABSD_MATHABSD_STALABSD_STDESUPP_STDEABSD_STGE/KE/SE/STSUPP_STSESUPP_STSE_COMPDATEABSD_TANKERABSD_TECH_MANABSD_UPDATE_FP_MACHINERY

spCreateNewShipWithNCON_CONFI — Confidential Newbuild

spCreateNewShipWithNCON_CONFI @PASSEDLRNO varchar(7), @PASSEDEFD varchar(8) [same optional params as spCreateNewShipWithStatus]

Identical to spCreateNewShipWithStatus but additionally:

spPreLoadNewShipWithStatusA — Pre-load Creation

spPreLoadNewShipWithStatusA @PASSEDLRNO varchar(7), @PASSEDEFD varchar(8) [similar params]

Creates a minimal vessel record for pre-load use (before confirmed IMO allocation). Inserts the same 62 tables as spCreateNewShipWithStatus but with 'PRE' source markers and leaves many fields at unknowns ('UNK'). Used when a provisional LRNO is needed before full data is available. The spPreLoadLRNOs / spGetPreLoadedLRNOs SPs manage the pre-load LRNO pool.

spDeleteShip — Full Vessel Deletion

spDeleteShip @PASSEDLRNO varchar(7)

Deletes all rows for the given LRNO from all ~62 ABSD_ tables plus SUPPLEMENTAL_ and tbl* tables. Called in two contexts:

  1. Integrity rollback: Called by spCreateNewShipWithStatus when the post-creation integrity check fails.
  2. User-initiated deletion: Called from the ship administration UI after all history has been confirmed cleared.
No soft-delete. spDeleteShip is destructive and immediate. There is no recycle bin. The ABSD_SHIPSDEL_UPDATES table receives an audit entry, but data is permanently removed. Before calling, the application UI requires confirmation plus spShipDeleteReset to clear any dependent records.

spShipDeleteReset — Pre-deletion Cleanup

spShipDeleteReset @PASSEDLRNO varchar(7)

Resets all history table records to SEQNO='00' and clears cascade-created secondary records before spDeleteShip is called. Ensures the ship has no dangling HIPP/HITP/OWSH rows that would survive deletion due to foreign-key-like dependencies managed by triggers.

spUpdateShipStatus — Status Code Change

spUpdateShipStatus @PASSEDLRNO varchar(7), @PASSEDSTATUS char(1), @PASSEDEFD varchar(8)

Updates ABSD_HIST.A02_STS for a vessel. The ABSD_HIST trigger fires on this change and drives extensive cascade logic (see Section 10 ABSD_HIST trigger for full detail). Key cascades triggered:

spUpdateShipWithStatus

spUpdateShipWithStatus @PASSEDLRNO varchar(7), @PASSEDSTATUS char(1), @PASSEDEFD varchar(8), @NewName varchar(50)=NULL, @NewFlag varchar(3)=NULL

Extended version of spUpdateShipStatus that additionally accepts a new name and/or new flag state. Used when a status change coincides with a name or registration change (common at newbuild delivery: O→S transition). Updates ABSD_HIST, ABSD_OVNA, and ABSD_HIFL in one operation.

spStatusChangeToSS — Split/Salvage Status

spStatusChangeToSS @PASSEDLRNO varchar(7), @PASSEDEFD varchar(8)

Handles the special case of a vessel transitioning to 'SS' (Split/Salvage) status. Unlike a normal status update, this procedure:

spNEWCONDateRollForward Phase 1/2/3

spNEWCONDateRollForwardPhase1 — Identify vessels with NCON dates to advance
spNEWCONDateRollForwardPhase2 — Apply date advances to SUPPLEMENTAL_ABSD_NCON
spNEWCONDateRollForwardPhase3 — Write annotations for all advanced dates

Three-phase process for advancing newbuild (NCON) estimated delivery dates when a vessel misses a quarter. Run on a scheduled basis:

Companion report SPs: spNEWCONDateRollForwardPhase1Rpt, spNEWCONDateRollForwardPhase2Rpt, spNEWCONDateRollForwardPhase3Rpt — return the affected vessel set without making changes (dry-run mode).

spNewConOrdersUpdate

spNewConOrdersUpdate

Bulk SP that refreshes the newbuild orders summary data from the current ABSD_HIST + SUPPLEMENTAL_ABSD_NCON state. Called by the scheduled job that feeds the newbuild orders reporting tables. Does not take parameters — processes all active newbuild records in one batch.

spMakeNewCas — Create New Casualty Record

spMakeNewCas @PASSEDLRNO varchar(7)

Creates a new ABSD_OVCA (casualty) record for a vessel by:

  1. Re-sequence existing records: Cursor over existing ABSD_OVCA rows for this LRNO ordered DESC. Each row's SEQ_NO is incremented by 1 (the REPLICATE pad-to-2 pattern handles leading zero).
  2. Insert new '01' record: INSERT INTO ABSD_OVCA VALUES (@PASSEDLRNO,'01','000000','RB CONV ',null, NULL). The new current record is SEQ_NO='01'; all prior records have been pushed to '02', '03', etc.
Note: ABSD_OVCA uses a reverse-sequence convention from ABSD_ history tables: '01' is the most-recent casualty, not the oldest. New casualties are always inserted as '01'.

spCreateNewCasualty / spCreateNewCasualtyExistingINNO

spCreateNewCasualty @PASSEDLRNO varchar(7), @PASSEDEFD varchar(8), @CasType char(2)='00'
spCreateNewCasualtyExisitingINNO @PASSEDLRNO varchar(7), @INNO varchar(4), @PASSEDEFD varchar(8)

spCreateNewCasualty — Creates the full casualty record suite for a vessel:

spCreateNewCasualtyExisitingINNO — Creates sub-records for a casualty that already has a CAGE1/INNO (used when adding a follow-on event to an existing incident).

spCasualtyOtherShips

spCasualtyOtherShips @INNO varchar(4)

Returns all vessels involved in the same casualty incident (same INNO across ABSD_CAGE1). Used by the casualty UI to show "other ships in this incident" for collision/grounding events with multiple vessels.

spShipExists

spShipExists @PASSEDLRNO varchar(7) — RETURNS 0 (exists) or 1 (not found)

Quick existence check. Returns 0 if ABSD_OVGE has a row for the LRNO, 1 if not. Used as a guard before any create operation to prevent duplicate LRNO inserts. Also used by TIP/MIS processing to skip vessels that have been deleted.

spShipHeaderQuick

spShipHeaderQuick @PASSEDLRNO varchar(7)

Returns a minimal vessel header record for UI display: LRNO, current name (ABSD_OVNA), current flag (ABSD_HIFL), current status (ABSD_HIST), gross tonnage (ABSD_HITL), year of build (ABSD_STSE), and ship type (ABSD_OVTY). Single SELECT joining 6 tables filtered by SEQNO='00'. Companion SP spFleetDetails / spFleetDetailsQuick return fleet-level summaries with similar field sets.

spShipTimeline

spShipTimeline @PASSEDLRNO varchar(7)

Returns the complete chronological timeline of key events for a vessel, unioning records from ABSD_HIST (status changes), ABSD_HIOW (ownership changes), ABSD_HIFL (flag changes), ABSD_OVNA (name changes), and ABSD_HILC (class changes). Each row includes the effective date (converted via fnLRDateToRealDate), event type, and old/new value. Used by the vessel history viewer in the UI and by the APS narrative generator for timeline-based text.

Section 12b  ·  LR Maritime Database Documentation  ·  2026-05-03