dbo.proper())IF NOT EXISTS (SELECT * FROM TRIGGER_DISABLE) guard. CBCA and CBFT are exceptions — they have no guard and always fire.
TRUD (trade/use decode) is inserted, immediately computes and stores APSProperTRUD = dbo.APSProper(TRUD) back on the same rowdbo.APSProper() is a scalar function that applies title-case formatting (capitalises first letter of each word)WMKR='W'), the trigger checks if the code is still in use on vessel recordsABSD_FUCA2.D08_STOWAGE references. If any exist, raises: "Stowage code still exists on vessels, please correct" and rolls backABSD_FUCA2.D08_COMMODITY references. If any exist, raises: "Commodity code still exists on vessels, please correct" and rolls backTRUD changes, recomputes APSProperTRUD = dbo.APSProper(TRUD)insertedTABLE_CODE + DECODE) with the current inserted rowABSD_CBCA_UPDATES staging table for downstream APS consumptionOUT_NOTE_SEQ_NO='00' and OUT_CONO_KEY starts with 'E' or 'S' (fleet/shipbuilder type), the trigger dissects the combined 70-character note line into 6-character shipbuilder cross-reference codesBLDR_XREF rows for this CNTRY+CDE1 and re-inserts from the parsed noteOUT_TYPE='S') with sequence numbers above '19', the note text is written to BLDR_TEXT as history lines (TYPE='H')OUT_NOTE_SEQ_NO - 19 (zero-padded to 2 digits)OUT_CODE_REST from ABSD_CBCOROOT to derive CDE2 and CD key componentsOUT_TYPE — each type class has entirely different downstream tables.GENSTYLE display string (25 chars) from OUT_SHORT_NAME and status prefix'T' = one leading space; 'N' = three spaces; 'W' = four spaces; default = no prefixAPPEND_GENSTYLE suffix logic (mutually exclusive priority order):
OUT_TO has value → append -YY (last 2 digits of TO year)OUT_FROM → append YY- (FROM year)#XREF_YARDABSD_CBEB row for this MM key, then inserts new row with DECODE_1, DECODE_2, GENSTYLE, HIST, TOWN, DELTABSD_CBCONAME (OUTNAME1+OUTNAME2) for this keyABSD_CBSB row with KEYC/KEYG/KEYN/KEYX/STYLE/DECODEA/DECODEB/HIST/TOWN/DELTBLDR_TEXT TYPE='A' (address, up to 6 lines) from ABSD_CBCOADDR SEQNO='00'BLDR_TEXT TYPE='P' (phone/contact) from ABSD_CBCOCOMM:
SEQNO 01=Phone, 02=Fax, 03=Telex, 04=Email, 05=Web — prefixed with label ("Phone: ", etc.)'C'=closed; else if OUT_TYPE_IND in (H,X,R) → use OUT_TYPE_IND; else use OUT_STATUSABSD_CBCOADDR (must be 4 chars, else NULL)UPDATE(OUT_SHORT_NAME), updates SHORT_NAME_PCASE = dbo.proper(out_short_name) for the matching keyCODE, then inserts current row into ABSD_CBFT_UPDATESThe full port name is split into two 19-character halves for the mainframe-era TNS1/TNS2 fields in CBTO1. The split algorithm:
OUT_PUBD + OUT_NAME_FILLER into a single string; collapses all double-spaces into single spacesABSD_CBPPROOT.OUT_PPRO_TYPE:
P=no prefix, T=1 space, O=2 spaces, A=6 spaces, other=9 spacesTNS1 = SUBSTRING(name, 1, RETPOS); TNS2 = SUBSTRING(name, RETPOS+1, 19)ABSD_CBTO1 (INSERT if not exists, else UPDATE) for this CNTRY+TOWNOUT_PPNA_SEQ='90', the PUBD field holds the owner statistics line for this portOUT_PPRO_KEY must be exactly 7 characters; shorter keys raise: "Key must be 7 characters" and roll backOUT_PORT_SEQ changes, validates that SUBSTRING(OUT_PPRO_KEY,1,3) + OUT_PORT_SEQ (country + port sequence) is unique across all CBPPROOT recordsOUT_LLP_PORT_CODE (Lloyd's List Port grid reference) is supplied and changes, validates it is globally unique across all CBPPROOT recordsABSD_CBTO1.TCNT to OUT_LR_OFFICE for this CNTRY+TOWNOUT_LR_OFFICE is blank (' '), falls back to OUT_INDICATOR'C' if LATDEG between 0 and 360, else ' 'OUT_STRE_DELETE='1', the trigger deletes the corresponding row from ABSD_CBTO2 (rather than inserting/updating)STYL1, STYL2, STYL3 (three style/name fields for the street/district) to ABSD_CBTO2LEVEL5DECODE changes (IF UPDATE(LEVEL5DECODE))inserted settblMasterShipTypeXref where Stat5Code = @Level5tblMasterShipTypeXref.Stat5Decode = @Level5Decode for each matching rowtblFlexible_Bucket_CB.UNIQUE for the inserted FIELD_NAMEUNIQUE='Y', counts existing rows with the same KEY + FIELD_NAME combinationspGetUserSettings for user context; writes to tblChanges with LRNo = [KEY], ChangeType='Data Bucket', and Notes = FIELD_NAMEspGetUserSettingsOwners for user context; writes to tblChanges with CompanyNo = [KEY], ChangeType='Data Bucket', and Notes = FIELD_NAMEtblFlexible_Bucket_CB at audit timeFIELD_NAME is inserted or updated, validates it via dbo.fnCheckFlexDataBucketFieldName(@FIELD_NAME)0 if the field name contains special characters| Trigger | Event | Guard | Business Rule | Key Derived/Downstream Tables |
|---|---|---|---|---|
ABSD_CBUB1_Insert |
I | None | APSProperTRUD formatting on insert | ABSD_CBUB1.APSProperTRUD |
absd_cbub1UPDATE |
U | None | WMKR='W' withdrawal protection (FLDI 01/02); APSProperTRUD refresh | ABSD_FUCA2 check; ABSD_CBUB1.APSProperTRUD |
ABSD_CBCA_Update |
U/I | None | Simple staging | ABSD_CBCA_UPDATES |
ABSD_CBCONOTE_update |
U/I | Standard | SEQ='00' → BLDR_XREF (cross-refs); Type S + SEQ>'19' → BLDR_TEXT H | BLDR_XREF, BLDR_TEXT |
ABSD_CBCOROOT_Update |
U/I | Standard | Type F → CBEB; Type T → CBSB+BLDR_TEXT A/P; Type S → BLDR_NAME+BLDR_TEXT H/N/A/P+BLDR_XREF+SUPPLEMENTAL | ABSD_CBEB, ABSD_CBSB, BLDR_NAME, BLDR_TEXT, BLDR_XREF, SUPPLEMENTAL_ABSD_CBCOROOT |
ABSD_CBFT_Update |
U/I | None | Simple staging | ABSD_CBFT_UPDATES |
ABSD_CBPPNAME_Update |
U/I | Standard | Town name word-wrap (TNS1/TNS2); OWST1/OWST2 from SEQ='90'; CBTD search index | ABSD_CBTO1, ABSD_CBTD |
ABSD_CBPPROOT_Update |
U/I | Standard | Key length ≥7; PORT_SEQ + LLP_PORT_CODE uniqueness; coordinates; dock pages; LR office; CBPD full rebuild | ABSD_CBTO1 (TCNT/TNS1/TNS2), ABSD_CBPD |
ABSD_CBPPSTRE_Update |
U/I | Standard | STRE_DELETE='1' → delete from CBTO2; else insert/update street styles | ABSD_CBTO2 |
tblStatCode5_Update |
U/I | None (BEGIN/END block) | LEVEL5DECODE change → cascade Stat5Decode to all matching MasterShipTypeXref rows | tblMasterShipTypeXref |
tblFlexible_Bucket_UpdateInsert |
U/I | None | UNIQUE='Y' → prevent duplicate KEY+FIELD_NAME; dual-context tblChanges audit (Ship vs Owner) | tblChanges (via spGetUserSettings or spGetUserSettingsOwners) |
tblFlexibleBucketCB_Insert_Update |
U/I | None | FIELD_NAME special character validation via fnCheckFlexDataBucketFieldName | – (validation only) |