CREATE TABLE [dbo].[arg_model_pricing]
(
[pricing_id] [bigint] NOT NULL,
[model_uuid] [binary] (16) NOT NULL,
[begin_date] [datetime] NULL,
[expiration_date] [datetime] NULL,
[pricing_amount] [float] NULL,
[currency_type_code] [varchar] (3) COLLATE SQL_Latin1_General_CP1_CS_AS NULL,
[pricing_type_id] [bigint] NULL,
[part_number] [nvarchar] (100) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[reseller_uuid] [binary] (16) NULL,
[pricing_comment] [nvarchar] (255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[creation_user] [nvarchar] (255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[creation_date] [int] NULL,
[last_update_user] [nvarchar] (255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[last_update_date] [int] NULL,
[version_number] [int] NULL CONSTRAINT [DF__ARG_MODEL__VERSI__629A9179] DEFAULT ('0 '),
[tenant] [binary] (16) NULL,
[is_manufacturer_part_number] [int] NULL
) ON [PRIMARY]
GO
CREATE TRIGGER dbo.ca_tr_del_arg_model_pricing
ON dbo.arg_model_pricing
FOR DELETE AS
DECLARE
@audit_product nvarchar(64)
SET @audit_product = APP_NAME()
INSERT INTO dbo.aud_arg_model_pricing (
AUDIT_TRAIL_PRODUCT,
AUDIT_TRAIL_USER,
AUDIT_TRAIL_TYPE,
AUDIT_TRAIL_DATE,
pricing_id,
model_uuid,
begin_date,
expiration_date,
pricing_amount,
currency_type_code,
pricing_type_id,
part_number,
reseller_uuid,
pricing_comment,
creation_user,
creation_date,
last_update_user,
last_update_date,
version_number,
tenant,
is_manufacturer_part_number) SELECT
@audit_product,old.last_update_user, 'DELETE', datediff(ss, '1/1/1970', getutcdate()),
old.pricing_id,
old.model_uuid,
old.begin_date,
old.expiration_date,
old.pricing_amount,
old.currency_type_code,
old.pricing_type_id,
old.part_number,
old.reseller_uuid,
old.pricing_comment,
old.creation_user,
old.creation_date,
old.last_update_user,
old.last_update_date,
old.version_number,
old.tenant,
old.is_manufacturer_part_number
FROM deleted old
GO
CREATE TRIGGER dbo.ca_tr_ins_arg_model_pricing
ON dbo.arg_model_pricing
FOR INSERT AS
DECLARE
@audit_product nvarchar(64)
SET @audit_product = APP_NAME()
INSERT INTO dbo.aud_arg_model_pricing (
AUDIT_TRAIL_PRODUCT,
AUDIT_TRAIL_USER,
AUDIT_TRAIL_TYPE,
AUDIT_TRAIL_DATE,
pricing_id,
model_uuid,
begin_date,
expiration_date,
pricing_amount,
currency_type_code,
pricing_type_id,
part_number,
reseller_uuid,
pricing_comment,
creation_user,
creation_date,
last_update_user,
last_update_date,
version_number,
tenant,
is_manufacturer_part_number) SELECT
@audit_product, new.last_update_user, 'INSERT', datediff(ss, '1/1/1970', getutcdate()),
new.pricing_id,
new.model_uuid,
new.begin_date,
new.expiration_date,
new.pricing_amount,
new.currency_type_code,
new.pricing_type_id,
new.part_number,
new.reseller_uuid,
new.pricing_comment,
new.creation_user,
new.creation_date,
new.last_update_user,
new.last_update_date,
new.version_number,
new.tenant,
new.is_manufacturer_part_number
FROM inserted new
GO
CREATE TRIGGER dbo.ca_tr_upd_arg_model_pricing
ON dbo.arg_model_pricing
FOR UPDATE AS
DECLARE
@audit_product nvarchar(64),
@last_update_user nvarchar(64),
@version_number int
SET @audit_product = APP_NAME()
SELECT @version_number = version_number, @last_update_user = last_update_user FROM inserted
IF @version_number != -1
INSERT INTO dbo.aud_arg_model_pricing (
AUDIT_TRAIL_PRODUCT,
AUDIT_TRAIL_USER,
AUDIT_TRAIL_TYPE,
AUDIT_TRAIL_DATE,
pricing_id,
model_uuid,
begin_date,
expiration_date,
pricing_amount,
currency_type_code,
pricing_type_id,
part_number,
reseller_uuid,
pricing_comment,
creation_user,
creation_date,
last_update_user,
last_update_date,
version_number,
tenant,
is_manufacturer_part_number) SELECT
@audit_product, new.last_update_user, 'UPDATE', datediff(ss, '1/1/1970', getutcdate()),
new.pricing_id,
new.model_uuid,
new.begin_date,
new.expiration_date,
new.pricing_amount,
new.currency_type_code,
new.pricing_type_id,
new.part_number,
new.reseller_uuid,
new.pricing_comment,
new.creation_user,
new.creation_date,
new.last_update_user,
new.last_update_date,
new.version_number,
new.tenant,
new.is_manufacturer_part_number
FROM inserted new
GO
ALTER TABLE [dbo].[arg_model_pricing] ADD CONSTRAINT [pk_arg_model_pricing] PRIMARY KEY CLUSTERED ([pricing_id]) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [arg_model_pricing_idx_01] ON [dbo].[arg_model_pricing] ([model_uuid]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[arg_model_pricing] ADD CONSTRAINT [FK_ARG_MODEL_PRICING_CURRENCY] FOREIGN KEY ([currency_type_code]) REFERENCES [dbo].[ca_currency_type] ([currency_type_code])
GO
ALTER TABLE [dbo].[arg_model_pricing] ADD CONSTRAINT [FK_ARG_MODEL_PRICING_MODEL] FOREIGN KEY ([model_uuid]) REFERENCES [dbo].[ca_model_def] ([model_uuid])
GO
ALTER TABLE [dbo].[arg_model_pricing] ADD CONSTRAINT [FK_ARG_MODEL_PRICING_RESELLER] FOREIGN KEY ([reseller_uuid]) REFERENCES [dbo].[ca_company] ([company_uuid])
GO
ALTER TABLE [dbo].[arg_model_pricing] ADD CONSTRAINT [FK_ARG_MODEL_PRICING_TENANT] FOREIGN KEY ([tenant]) REFERENCES [dbo].[ca_tenant] ([id])
GO
ALTER TABLE [dbo].[arg_model_pricing] ADD CONSTRAINT [FK_ARG_MODEL_PRICING_TYPE] FOREIGN KEY ([pricing_type_id]) REFERENCES [dbo].[arg_pricing_type] ([id])
GO