Skip to content

Commit

Permalink
IS-55.00 Regenerated Schema (bcgov#3209)
Browse files Browse the repository at this point in the history
* IS-55.00 Database Schema

PSP_PIMS S55.00 Sprint 55 2023-May-26
- Added tables:
  - PIMS_ACQUISITION_OWNER_REP
  - PIMS_ACQUISITION_OWNER_REP_HIST
  - PIMS_INTEREST_HOLDER
  - PIMS_INTEREST_HOLDER_HIST
  - PIMS_INTEREST_HOLDER_INTEREST_TYPE
  - PIMS_INTHLDR_PROP_INTEREST
  - PIMS_INTHLDR_PROP_INTEREST_HIST
- Altered tables:
  - PIMS_ACQ_CHKLST_ITEM_TYPE
  - PIMS_ACQ_CHKLST_SECTION_TYPE
  - PIMS_ACQ_PAYEE_CHEQUE
  - PIMS_ACQ_PAYEE_CHEQUE_HIST
  - PIMS_ACQUISITION_PAYEE
  - PIMS_ACQUISITION_PAYEE_HIST
- Added seed scripts:
  - 130_DML_PIMS_INTEREST_HOLDER_INTEREST_TYPE.sql
- Altered seed scripts:
  - 120_DML_PIMS_ACQ_CHKLST_SECTION_TYPE.sql
  - 121_DML_PIMS_ACQ_CHKLST_ITEM_TYPE.sql
- Requires additional metadata to meet standards

* Added Spatial Indicies

Added the conditional creation of spatial indices in PIMS_PROPERTY
- 005_PSP_PIMS_PROPERTY_SPATIAL_IDX.sql

* Added Deletion of Dynamic Constraints to Alter Up

003_Delete_DynamicConstraint.sql

* Added Foreign Key

Added foreign key between Acquisition File and Interest Holder

* Dropped FK Script in Alter Down

* Added Payment in Trust

Added IS_PAYMENT_IN_TRUST to PIMS_ACQ_PAYEE_CHEQUE

* IS-55.00 Regenerated Schema

Regenerated to address spurious errors.

PSP_PIMS S55.00 Sprint 55 2023-May-26
- Added tables:
  - PIMS_ACQUISITION_OWNER_REP
  - PIMS_ACQUISITION_OWNER_REP_HIST
  - PIMS_INTEREST_HOLDER
  - PIMS_INTEREST_HOLDER_HIST
  - PIMS_INTEREST_HOLDER_INTEREST_TYPE
  - PIMS_INTHLDR_PROP_INTEREST
  - PIMS_INTHLDR_PROP_INTEREST_HIST
- Altered tables:
  - PIMS_ACQ_CHKLST_ITEM_TYPE
  - PIMS_ACQ_CHKLST_SECTION_TYPE
  - PIMS_ACQ_PAYEE_CHEQUE
  - PIMS_ACQ_PAYEE_CHEQUE_HIST
  - PIMS_ACQUISITION_PAYEE
  - PIMS_ACQUISITION_PAYEE_HIST
- Added seed scripts:
  - 130_DML_PIMS_INTEREST_HOLDER_INTEREST_TYPE.sql
- Altered seed scripts:
  - 120_DML_PIMS_ACQ_CHKLST_SECTION_TYPE.sql
  - 121_DML_PIMS_ACQ_CHKLST_ITEM_TYPE.sql
- Requires additional metadata to meet standards

* Fixed PIMS_INTHLDR_PROP_INTEREST

VARCHAR(40) changed to BIGINT
  • Loading branch information
dfilteau authored and Smith committed May 31, 2023
1 parent 44afc2b commit 177b390
Show file tree
Hide file tree
Showing 17 changed files with 368 additions and 482 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
-- Script generated by Aqua Data Studio Schema Synchronization for MS SQL Server 2016 on Fri May 26 13:07:41 PDT 2023
-- Script generated by Aqua Data Studio Schema Synchronization for MS SQL Server 2016 on Tue May 30 16:17:33 PDT 2023
-- Execute this script on:
-- PIMS_PSP_S55_00/dbo - This database/schema will be modified
-- to synchronize it with MS SQL Server 2016:
Expand Down Expand Up @@ -138,6 +138,15 @@ GO
IF @@ERROR <> 0 SET NOEXEC ON
GO

-- Drop foreign key constraint dbo.PIM_ACQNFL_PIM_INTHLD_FK
PRINT N'Drop foreign key constraint dbo.PIM_ACQNFL_PIM_INTHLD_FK'
GO
ALTER TABLE [dbo].[PIMS_INTEREST_HOLDER]
DROP CONSTRAINT IF EXISTS [PIM_ACQNFL_PIM_INTHLD_FK]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO

-- Drop index dbo.IHPRIN_PROPERTY_ACQUISITION_FILE_ID_IDX
PRINT N'Drop index dbo.IHPRIN_PROPERTY_ACQUISITION_FILE_ID_IDX'
GO
Expand Down Expand Up @@ -521,29 +530,13 @@ GO
IF @@ERROR <> 0 SET NOEXEC ON
GO

-- Drop sequence dbo.PIMS_ACQUISITION_FILE_STAKEHOLDER_ID_SEQ
PRINT N'Drop sequence dbo.PIMS_ACQUISITION_FILE_STAKEHOLDER_ID_SEQ'
GO
DROP SEQUENCE IF EXISTS [dbo].[PIMS_ACQUISITION_FILE_STAKEHOLDER_ID_SEQ]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO

-- Alter table dbo.PIMS_ACQUISITION_PAYEE
PRINT N'Alter table dbo.PIMS_ACQUISITION_PAYEE'
GO
--UPDATE [dbo].[PIMS_ACQUISITION_PAYEE] SET [ACQUISITION_OWNER_ID] = -1 WHERE [ACQUISITION_OWNER_ID] IS NULL
--GO
--IF @@ERROR <> 0 SET NOEXEC ON
--GO
ALTER TABLE [dbo].[PIMS_ACQUISITION_PAYEE] ALTER COLUMN [ACQUISITION_OWNER_ID] bigint NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
--ALTER TABLE [dbo].[PIMS_ACQUISITION_PAYEE] ADD DEFAULT -1 FOR [ACQUISITION_OWNER_ID]
--GO
--IF @@ERROR <> 0 SET NOEXEC ON
--GO
ALTER TABLE [dbo].[PIMS_ACQUISITION_PAYEE]
DROP COLUMN IF EXISTS [INTEREST_HOLDER_ID], [OWNER_REPRESENTATIVE_ID], [OWNER_SOLICITOR_ID], [ACQUISITION_FILE_PERSON_ID]
GO
Expand All @@ -553,18 +546,10 @@ GO
-- Alter table dbo.PIMS_ACQUISITION_PAYEE_HIST
PRINT N'Alter table dbo.PIMS_ACQUISITION_PAYEE_HIST'
GO
--UPDATE [dbo].[PIMS_ACQUISITION_PAYEE_HIST] SET [ACQUISITION_OWNER_ID] = -1 WHERE [ACQUISITION_OWNER_ID] IS NULL
--GO
--IF @@ERROR <> 0 SET NOEXEC ON
--GO
ALTER TABLE [dbo].[PIMS_ACQUISITION_PAYEE_HIST] ALTER COLUMN [ACQUISITION_OWNER_ID] bigint NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
--ALTER TABLE [dbo].[PIMS_ACQUISITION_PAYEE_HIST] ADD DEFAULT -1 FOR [ACQUISITION_OWNER_ID]
--GO
--IF @@ERROR <> 0 SET NOEXEC ON
--GO
ALTER TABLE [dbo].[PIMS_ACQUISITION_PAYEE_HIST]
DROP COLUMN IF EXISTS [INTEREST_HOLDER_ID], [OWNER_REPRESENTATIVE_ID], [OWNER_SOLICITOR_ID], [ACQUISITION_FILE_PERSON_ID]
GO
Expand All @@ -574,6 +559,11 @@ GO
-- Alter table dbo.PIMS_ACQ_PAYEE_CHEQUE
PRINT N'Alter table dbo.PIMS_ACQ_PAYEE_CHEQUE'
GO
ALTER TABLE [dbo].[PIMS_ACQ_PAYEE_CHEQUE]
DROP CONSTRAINT IF EXISTS [AQPCHQ_IS_PAYMENT_IN_TRUST_DEF]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[PIMS_ACQ_PAYEE_CHEQUE]
ADD [IS_GST_REQUIRED] bit NULL CONSTRAINT [AQPCHQ_IS_GST_REQUIRED_DEF] DEFAULT (CONVERT([bit],(0)))
GO
Expand All @@ -586,7 +576,7 @@ GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[PIMS_ACQ_PAYEE_CHEQUE]
DROP COLUMN IF EXISTS [GST_NUMBER]
DROP COLUMN IF EXISTS [GST_NUMBER], [IS_PAYMENT_IN_TRUST]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
Expand All @@ -600,7 +590,7 @@ GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[PIMS_ACQ_PAYEE_CHEQUE_HIST]
DROP COLUMN IF EXISTS [GST_NUMBER]
DROP COLUMN IF EXISTS [GST_NUMBER], [IS_PAYMENT_IN_TRUST]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
Expand All @@ -612,10 +602,6 @@ ALTER TABLE [dbo].[PIMS_ACQ_CHKLST_SECTION_TYPE] DROP CONSTRAINT IF EXISTS [AQCS
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
--ALTER TABLE [dbo].[PIMS_ACQ_CHKLST_SECTION_TYPE] ADD DEFAULT getutcdate() FOR [EFFECTIVE_DATE]
--GO
--IF @@ERROR <> 0 SET NOEXEC ON
--GO

-- Alter table dbo.PIMS_ACQ_CHKLST_ITEM_TYPE
PRINT N'Alter table dbo.PIMS_ACQ_CHKLST_ITEM_TYPE'
Expand All @@ -624,10 +610,6 @@ ALTER TABLE [dbo].[PIMS_ACQ_CHKLST_ITEM_TYPE] DROP CONSTRAINT IF EXISTS [ACQCIT_
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
--ALTER TABLE [dbo].[PIMS_ACQ_CHKLST_ITEM_TYPE] ADD DEFAULT getutcdate() FOR [EFFECTIVE_DATE]
--GO
--IF @@ERROR <> 0 SET NOEXEC ON
--GO

-- Create index dbo.ACQPAY_ACQUISITION_OWNER_ID_IDX
PRINT N'Create index dbo.ACQPAY_ACQUISITION_OWNER_ID_IDX'
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
-- Script generated by Aqua Data Studio Schema Synchronization for MS SQL Server 2016 on Fri May 26 13:03:56 PDT 2023
-- Script generated by Aqua Data Studio Schema Synchronization for MS SQL Server 2016 on Tue May 30 16:14:09 PDT 2023
-- Execute this script on:
-- PIMS_PSP_S54_00/dbo - This database/schema will be modified
-- to synchronize it with MS SQL Server 2016:
Expand Down Expand Up @@ -63,21 +63,6 @@ GO
IF @@ERROR <> 0 SET NOEXEC ON
GO

---- Create sequence dbo.PIMS_ACQUISITION_FILE_STAKEHOLDER_ID_SEQ
--PRINT N'Create sequence dbo.PIMS_ACQUISITION_FILE_STAKEHOLDER_ID_SEQ'
--GO
--CREATE SEQUENCE [dbo].[PIMS_ACQUISITION_FILE_STAKEHOLDER_ID_SEQ]
-- AS bigint
-- START WITH 1
-- INCREMENT BY 1
-- MINVALUE 1
-- MAXVALUE 2147483647
-- NO CYCLE
-- CACHE 50
--GO
--IF @@ERROR <> 0 SET NOEXEC ON
--GO

-- Create sequence dbo.PIMS_INTHLDR_PROP_INTEREST_ID_SEQ
PRINT N'Create sequence dbo.PIMS_INTHLDR_PROP_INTEREST_ID_SEQ'
GO
Expand Down Expand Up @@ -128,6 +113,7 @@ PRINT N'Create table dbo.PIMS_INTEREST_HOLDER'
GO
CREATE TABLE [dbo].[PIMS_INTEREST_HOLDER] (
[INTEREST_HOLDER_ID] bigint NOT NULL CONSTRAINT [INTHLD_INTEREST_HOLDER_ID_DEF] DEFAULT (NEXT VALUE FOR [PIMS_INTEREST_HOLDER_ID_SEQ]),
[ACQUISITION_FILE_ID] bigint NOT NULL,
[PERSON_ID] bigint NULL,
[ORGANIZATION_ID] bigint NULL,
[IS_DISABLED] bit NULL CONSTRAINT [INTHLD_IS_DISABLED_DEF] DEFAULT (CONVERT([bit],(0))),
Expand Down Expand Up @@ -235,7 +221,7 @@ GO
PRINT N'Create table dbo.PIMS_INTHLDR_PROP_INTEREST'
GO
CREATE TABLE [dbo].[PIMS_INTHLDR_PROP_INTEREST] (
[PIMS_INTHLDR_PROP_INTEREST_ID] varchar(40) NOT NULL CONSTRAINT [IHPRIN_PIMS_INTHLDR_PROP_INTEREST_ID_DEF] DEFAULT ('NEXT VALUE FOR [PIMS_INTHLDR_PROP_INTEREST_ID_SEQ]'),
[PIMS_INTHLDR_PROP_INTEREST_ID] bigint NOT NULL CONSTRAINT [IHPRIN_PIMS_INTHLDR_PROP_INTEREST_ID_DEF] DEFAULT ('NEXT VALUE FOR [PIMS_INTHLDR_PROP_INTEREST_ID_SEQ]'),
[INTEREST_HOLDER_ID] bigint NOT NULL,
[PROPERTY_ACQUISITION_FILE_ID] bigint NULL,
[INTEREST_HOLDER_INTEREST_TYPE_CODE] nvarchar(20) NOT NULL,
Expand Down Expand Up @@ -460,7 +446,8 @@ GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[PIMS_ACQ_PAYEE_CHEQUE]
ADD [GST_NUMBER] nvarchar(50) NULL
ADD [GST_NUMBER] nvarchar(50) NULL,
[IS_PAYMENT_IN_TRUST] bit NULL CONSTRAINT [AQPCHQ_IS_PAYMENT_IN_TRUST_DEF] DEFAULT (CONVERT([bit],(0)))
GO
EXEC sp_addextendedproperty
@name = N'MS_Description', @value = N'GST number of the Payee' ,
Expand All @@ -480,7 +467,8 @@ GO
PRINT N'Alter table dbo.PIMS_ACQ_PAYEE_CHEQUE_HIST'
GO
ALTER TABLE [dbo].[PIMS_ACQ_PAYEE_CHEQUE_HIST]
ADD [GST_NUMBER] nvarchar(50) NULL
ADD [GST_NUMBER] nvarchar(50) NULL,
[IS_PAYMENT_IN_TRUST] bit NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
Expand Down Expand Up @@ -513,6 +501,7 @@ CREATE TABLE [dbo].[PIMS_INTEREST_HOLDER_HIST] (
[EFFECTIVE_DATE_HIST] datetime NOT NULL DEFAULT (getutcdate()),
[END_DATE_HIST] datetime NULL,
[INTEREST_HOLDER_ID] bigint NOT NULL,
[ACQUISITION_FILE_ID] bigint NOT NULL,
[PERSON_ID] bigint NULL,
[ORGANIZATION_ID] bigint NULL,
[IS_DISABLED] bit NULL,
Expand Down Expand Up @@ -570,7 +559,7 @@ CREATE TABLE [dbo].[PIMS_INTHLDR_PROP_INTEREST_HIST] (
[_INTHLDR_PROP_INTEREST_HIST_ID] bigint NOT NULL DEFAULT (NEXT VALUE FOR [PIMS_INTHLDR_PROP_INTEREST_H_ID_SEQ]),
[EFFECTIVE_DATE_HIST] datetime NOT NULL DEFAULT (getutcdate()),
[END_DATE_HIST] datetime NULL,
[PIMS_INTHLDR_PROP_INTEREST_ID] varchar(40) NOT NULL,
[PIMS_INTHLDR_PROP_INTEREST_ID] bigint NOT NULL,
[INTEREST_HOLDER_ID] bigint NOT NULL,
[PROPERTY_ACQUISITION_FILE_ID] bigint NULL,
[INTEREST_HOLDER_INTEREST_TYPE_CODE] nvarchar(20) NOT NULL,
Expand Down Expand Up @@ -722,6 +711,19 @@ GO
IF @@ERROR <> 0 SET NOEXEC ON
GO

-- Create foreign key constraint dbo.PIM_ACQNFL_PIM_INTHLD_FK
PRINT N'Create foreign key constraint dbo.PIM_ACQNFL_PIM_INTHLD_FK'
GO
ALTER TABLE [dbo].[PIMS_INTEREST_HOLDER]
ADD CONSTRAINT [PIM_ACQNFL_PIM_INTHLD_FK]
FOREIGN KEY([ACQUISITION_FILE_ID])
REFERENCES [dbo].[PIMS_ACQUISITION_FILE]([ACQUISITION_FILE_ID])
ON DELETE NO ACTION
ON UPDATE NO ACTION
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO

-- Create foreign key constraint dbo.PIM_ORG_PIM_INTHLD_FK
PRINT N'Create foreign key constraint dbo.PIM_ORG_PIM_INTHLD_FK'
GO
Expand Down Expand Up @@ -1055,6 +1057,7 @@ BEGIN TRY


insert into PIMS_INTEREST_HOLDER ("INTEREST_HOLDER_ID",
"ACQUISITION_FILE_ID",
"PERSON_ID",
"ORGANIZATION_ID",
"IS_DISABLED",
Expand All @@ -1068,6 +1071,7 @@ BEGIN TRY
"APP_LAST_UPDATE_USER_GUID",
"APP_LAST_UPDATE_USER_DIRECTORY")
select "INTEREST_HOLDER_ID",
"ACQUISITION_FILE_ID",
"PERSON_ID",
"ORGANIZATION_ID",
"IS_DISABLED",
Expand Down Expand Up @@ -1170,6 +1174,7 @@ BEGIN TRY
"TAX_AMT" = inserted."TAX_AMT",
"TOTAL_AMT" = inserted."TOTAL_AMT",
"GST_NUMBER" = inserted."GST_NUMBER",
"IS_PAYMENT_IN_TRUST" = inserted."IS_PAYMENT_IN_TRUST",
"CONCURRENCY_CONTROL_NUMBER" = inserted."CONCURRENCY_CONTROL_NUMBER",
"APP_LAST_UPDATE_TIMESTAMP" = inserted."APP_LAST_UPDATE_TIMESTAMP",
"APP_LAST_UPDATE_USERID" = inserted."APP_LAST_UPDATE_USERID",
Expand Down Expand Up @@ -1207,8 +1212,8 @@ SET @curr_date = getutcdate();
update PIMS_ACQ_PAYEE_CHEQUE_HIST set END_DATE_HIST = @curr_date where ACQ_PAYEE_CHEQUE_ID in (select ACQ_PAYEE_CHEQUE_ID from deleted) and END_DATE_HIST is null;

IF EXISTS(SELECT * FROM inserted)
insert into PIMS_ACQ_PAYEE_CHEQUE_HIST ([ACQ_PAYEE_CHEQUE_ID], [ACQUISITION_PAYEE_ID], [PRETAX_AMT], [TAX_AMT], [TOTAL_AMT], [GST_NUMBER], [CONCURRENCY_CONTROL_NUMBER], [APP_CREATE_TIMESTAMP], [APP_CREATE_USERID], [APP_CREATE_USER_GUID], [APP_CREATE_USER_DIRECTORY], [APP_LAST_UPDATE_TIMESTAMP], [APP_LAST_UPDATE_USERID], [APP_LAST_UPDATE_USER_GUID], [APP_LAST_UPDATE_USER_DIRECTORY], [DB_CREATE_TIMESTAMP], [DB_CREATE_USERID], [DB_LAST_UPDATE_TIMESTAMP], [DB_LAST_UPDATE_USERID], _ACQ_PAYEE_CHEQUE_HIST_ID, END_DATE_HIST, EFFECTIVE_DATE_HIST)
select [ACQ_PAYEE_CHEQUE_ID], [ACQUISITION_PAYEE_ID], [PRETAX_AMT], [TAX_AMT], [TOTAL_AMT], [GST_NUMBER], [CONCURRENCY_CONTROL_NUMBER], [APP_CREATE_TIMESTAMP], [APP_CREATE_USERID], [APP_CREATE_USER_GUID], [APP_CREATE_USER_DIRECTORY], [APP_LAST_UPDATE_TIMESTAMP], [APP_LAST_UPDATE_USERID], [APP_LAST_UPDATE_USER_GUID], [APP_LAST_UPDATE_USER_DIRECTORY], [DB_CREATE_TIMESTAMP], [DB_CREATE_USERID], [DB_LAST_UPDATE_TIMESTAMP], [DB_LAST_UPDATE_USERID], (next value for [dbo].[PIMS_ACQ_PAYEE_CHEQUE_H_ID_SEQ]) as [_ACQ_PAYEE_CHEQUE_HIST_ID], null as [END_DATE_HIST], @curr_date as [EFFECTIVE_DATE_HIST] from inserted;
insert into PIMS_ACQ_PAYEE_CHEQUE_HIST ([ACQ_PAYEE_CHEQUE_ID], [ACQUISITION_PAYEE_ID], [PRETAX_AMT], [TAX_AMT], [TOTAL_AMT], [GST_NUMBER], [IS_PAYMENT_IN_TRUST], [CONCURRENCY_CONTROL_NUMBER], [APP_CREATE_TIMESTAMP], [APP_CREATE_USERID], [APP_CREATE_USER_GUID], [APP_CREATE_USER_DIRECTORY], [APP_LAST_UPDATE_TIMESTAMP], [APP_LAST_UPDATE_USERID], [APP_LAST_UPDATE_USER_GUID], [APP_LAST_UPDATE_USER_DIRECTORY], [DB_CREATE_TIMESTAMP], [DB_CREATE_USERID], [DB_LAST_UPDATE_TIMESTAMP], [DB_LAST_UPDATE_USERID], _ACQ_PAYEE_CHEQUE_HIST_ID, END_DATE_HIST, EFFECTIVE_DATE_HIST)
select [ACQ_PAYEE_CHEQUE_ID], [ACQUISITION_PAYEE_ID], [PRETAX_AMT], [TAX_AMT], [TOTAL_AMT], [GST_NUMBER], [IS_PAYMENT_IN_TRUST], [CONCURRENCY_CONTROL_NUMBER], [APP_CREATE_TIMESTAMP], [APP_CREATE_USERID], [APP_CREATE_USER_GUID], [APP_CREATE_USER_DIRECTORY], [APP_LAST_UPDATE_TIMESTAMP], [APP_LAST_UPDATE_USERID], [APP_LAST_UPDATE_USER_GUID], [APP_LAST_UPDATE_USER_DIRECTORY], [DB_CREATE_TIMESTAMP], [DB_CREATE_USERID], [DB_LAST_UPDATE_TIMESTAMP], [DB_LAST_UPDATE_USERID], (next value for [dbo].[PIMS_ACQ_PAYEE_CHEQUE_H_ID_SEQ]) as [_ACQ_PAYEE_CHEQUE_HIST_ID], null as [END_DATE_HIST], @curr_date as [EFFECTIVE_DATE_HIST] from inserted;

END TRY
BEGIN CATCH
Expand Down Expand Up @@ -1318,8 +1323,8 @@ SET @curr_date = getutcdate();
update PIMS_INTEREST_HOLDER_HIST set END_DATE_HIST = @curr_date where INTEREST_HOLDER_ID in (select INTEREST_HOLDER_ID from deleted) and END_DATE_HIST is null;

IF EXISTS(SELECT * FROM inserted)
insert into PIMS_INTEREST_HOLDER_HIST ([INTEREST_HOLDER_ID], [PERSON_ID], [ORGANIZATION_ID], [IS_DISABLED], [CONCURRENCY_CONTROL_NUMBER], [APP_CREATE_TIMESTAMP], [APP_CREATE_USERID], [APP_CREATE_USER_GUID], [APP_CREATE_USER_DIRECTORY], [APP_LAST_UPDATE_TIMESTAMP], [APP_LAST_UPDATE_USERID], [APP_LAST_UPDATE_USER_GUID], [APP_LAST_UPDATE_USER_DIRECTORY], [DB_CREATE_TIMESTAMP], [DB_CREATE_USERID], [DB_LAST_UPDATE_TIMESTAMP], [DB_LAST_UPDATE_USERID], _INTEREST_HOLDER_HIST_ID, END_DATE_HIST, EFFECTIVE_DATE_HIST)
select [INTEREST_HOLDER_ID], [PERSON_ID], [ORGANIZATION_ID], [IS_DISABLED], [CONCURRENCY_CONTROL_NUMBER], [APP_CREATE_TIMESTAMP], [APP_CREATE_USERID], [APP_CREATE_USER_GUID], [APP_CREATE_USER_DIRECTORY], [APP_LAST_UPDATE_TIMESTAMP], [APP_LAST_UPDATE_USERID], [APP_LAST_UPDATE_USER_GUID], [APP_LAST_UPDATE_USER_DIRECTORY], [DB_CREATE_TIMESTAMP], [DB_CREATE_USERID], [DB_LAST_UPDATE_TIMESTAMP], [DB_LAST_UPDATE_USERID], (next value for [dbo].[PIMS_INTEREST_HOLDER_H_ID_SEQ]) as [_INTEREST_HOLDER_HIST_ID], null as [END_DATE_HIST], @curr_date as [EFFECTIVE_DATE_HIST] from inserted;
insert into PIMS_INTEREST_HOLDER_HIST ([INTEREST_HOLDER_ID], [ACQUISITION_FILE_ID], [PERSON_ID], [ORGANIZATION_ID], [IS_DISABLED], [CONCURRENCY_CONTROL_NUMBER], [APP_CREATE_TIMESTAMP], [APP_CREATE_USERID], [APP_CREATE_USER_GUID], [APP_CREATE_USER_DIRECTORY], [APP_LAST_UPDATE_TIMESTAMP], [APP_LAST_UPDATE_USERID], [APP_LAST_UPDATE_USER_GUID], [APP_LAST_UPDATE_USER_DIRECTORY], [DB_CREATE_TIMESTAMP], [DB_CREATE_USERID], [DB_LAST_UPDATE_TIMESTAMP], [DB_LAST_UPDATE_USERID], _INTEREST_HOLDER_HIST_ID, END_DATE_HIST, EFFECTIVE_DATE_HIST)
select [INTEREST_HOLDER_ID], [ACQUISITION_FILE_ID], [PERSON_ID], [ORGANIZATION_ID], [IS_DISABLED], [CONCURRENCY_CONTROL_NUMBER], [APP_CREATE_TIMESTAMP], [APP_CREATE_USERID], [APP_CREATE_USER_GUID], [APP_CREATE_USER_DIRECTORY], [APP_LAST_UPDATE_TIMESTAMP], [APP_LAST_UPDATE_USERID], [APP_LAST_UPDATE_USER_GUID], [APP_LAST_UPDATE_USER_DIRECTORY], [DB_CREATE_TIMESTAMP], [DB_CREATE_USERID], [DB_LAST_UPDATE_TIMESTAMP], [DB_LAST_UPDATE_USERID], (next value for [dbo].[PIMS_INTEREST_HOLDER_H_ID_SEQ]) as [_INTEREST_HOLDER_HIST_ID], null as [END_DATE_HIST], @curr_date as [EFFECTIVE_DATE_HIST] from inserted;

END TRY
BEGIN CATCH
Expand Down Expand Up @@ -1347,6 +1352,7 @@ BEGIN TRY
"TAX_AMT",
"TOTAL_AMT",
"GST_NUMBER",
"IS_PAYMENT_IN_TRUST",
"CONCURRENCY_CONTROL_NUMBER",
"APP_CREATE_TIMESTAMP",
"APP_CREATE_USERID",
Expand All @@ -1362,6 +1368,7 @@ BEGIN TRY
"TAX_AMT",
"TOTAL_AMT",
"GST_NUMBER",
"IS_PAYMENT_IN_TRUST",
"CONCURRENCY_CONTROL_NUMBER",
"APP_CREATE_TIMESTAMP",
"APP_CREATE_USERID",
Expand Down Expand Up @@ -1479,6 +1486,7 @@ BEGIN TRY
-- update statement
update PIMS_INTEREST_HOLDER
set "INTEREST_HOLDER_ID" = inserted."INTEREST_HOLDER_ID",
"ACQUISITION_FILE_ID" = inserted."ACQUISITION_FILE_ID",
"PERSON_ID" = inserted."PERSON_ID",
"ORGANIZATION_ID" = inserted."ORGANIZATION_ID",
"IS_DISABLED" = inserted."IS_DISABLED",
Expand Down

This file was deleted.

This file was deleted.

Binary file not shown.
Loading

0 comments on commit 177b390

Please sign in to comment.