Tables [dbo].[al_purchase_order]
Properties
PropertyValue
Row Count4
Created12:30:41 PM Sunday, December 05, 2010
Last Modified10:34:21 PM Thursday, February 10, 2011
Columns
NameData TypeCollationMax Length (Bytes)Allow NullsDefault
Cluster Primary Key PK_al_purchase_order: purchase_order_idpurchase_order_idint4
No
purchase_order_numbernvarchar(255)SQL_Latin1_General_CP1_CI_AS510
Yes
purchase_order_datedatetime8
Yes
commentsnvarchar(2000)SQL_Latin1_General_CP1_CI_AS4000
Yes
signaturenvarchar(255)SQL_Latin1_General_CP1_CI_AS510
Yes
ship_to_overide_flagint4
Yes
Foreign Keys AL_PURCHASE_ORDER_FK03: [dbo].[ca_contact].ship_to_contact_uuidship_to_contact_uuidbinary(16)16
Yes
ship_to_location_addressnvarchar(255)SQL_Latin1_General_CP1_CI_AS510
Yes
billing_overide_flagint4
Yes
Foreign Keys AL_PURCHASE_ORDER_FK04: [dbo].[ca_location].billing_location_uuidbilling_location_uuidbinary(16)16
Yes
billing_addressnvarchar(255)SQL_Latin1_General_CP1_CI_AS510
Yes
reseller_overide_flagint4
Yes
Foreign Keys AL_PURCHASE_ORDER_FK05: [dbo].[ca_company].reseller_uuidreseller_uuidbinary(16)16
Yes
reseller_addressnvarchar(255)SQL_Latin1_General_CP1_CI_AS510
Yes
total_amountfloat8
Yes
total_tax_amountfloat8
Yes
sub_total_amountfloat8
Yes
Foreign Keys AL_PURCHASE_ORDER_FK01: [dbo].[ca_currency_type].currency_type_idcurrency_type_idvarchar(3)SQL_Latin1_General_CP1_CS_AS3
Yes
assets_createdint4
Yes
('0')
Foreign Keys AL_PURCHASE_ORDER_FK02: [dbo].[al_purchase_order_status].purchase_order_status_idpurchase_order_status_idint4
No
creation_usernvarchar(255)SQL_Latin1_General_CP1_CI_AS510
Yes
creation_dateint4
Yes
last_update_usernvarchar(255)SQL_Latin1_General_CP1_CI_AS510
Yes
last_update_dateint4
Yes
version_numberint4
Yes
('0')
Foreign Keys AL_PURCHASE_ORDER_FK07: [dbo].[ca_contact].buyer_contact_uuidbuyer_contact_uuidbinary(16)16
Yes
termsnvarchar(2000)SQL_Latin1_General_CP1_CI_AS4000
Yes
date_requireddatetime8
Yes
Foreign Keys AL_PURCHASE_ORDER_FK09: [dbo].[al_shipment_type].shipment_type_idshipment_type_idint4
Yes
Foreign Keys AL_PURCHASE_ORDER_FK08: [dbo].[ca_company].billing_company_uuidbilling_company_uuidbinary(16)16
Yes
Indexes Indexes
NameColumnsUnique
Cluster Primary Key PK_al_purchase_order: purchase_order_idPK_al_purchase_orderpurchase_order_id
Yes
Triggers Triggers
NameANSI Nulls OnQuoted Identifier OnOn
al_c_purchordr_tr
Yes
Yes
After Insert
al_d_purchordr_tr
Yes
Yes
Instead Of Delete
Foreign Keys Foreign Keys
NameColumns
AL_PURCHASE_ORDER_FK01currency_type_id->[dbo].[ca_currency_type].[currency_type_code]
AL_PURCHASE_ORDER_FK02purchase_order_status_id->[dbo].[al_purchase_order_status].[id]
AL_PURCHASE_ORDER_FK03ship_to_contact_uuid->[dbo].[ca_contact].[contact_uuid]
AL_PURCHASE_ORDER_FK04billing_location_uuid->[dbo].[ca_location].[location_uuid]
AL_PURCHASE_ORDER_FK05reseller_uuid->[dbo].[ca_company].[company_uuid]
AL_PURCHASE_ORDER_FK07buyer_contact_uuid->[dbo].[ca_contact].[contact_uuid]
AL_PURCHASE_ORDER_FK08billing_company_uuid->[dbo].[ca_company].[company_uuid]
AL_PURCHASE_ORDER_FK09shipment_type_id->[dbo].[al_shipment_type].[id]
Permissions
TypeActionOwning Principal
GrantDeleteswcmadmin
GrantInsertswcmadmin
GrantSelectswcmadmin
GrantUpdateswcmadmin
SQL Script
CREATE TABLE [dbo].[al_purchase_order]
(
[purchase_order_id] [int] NOT NULL,
[purchase_order_number] [nvarchar] (255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[purchase_order_date] [datetime] NULL,
[comments] [nvarchar] (2000) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[signature] [nvarchar] (255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[ship_to_overide_flag] [int] NULL,
[ship_to_contact_uuid] [binary] (16) NULL,
[ship_to_location_address] [nvarchar] (255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[billing_overide_flag] [int] NULL,
[billing_location_uuid] [binary] (16) NULL,
[billing_address] [nvarchar] (255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[reseller_overide_flag] [int] NULL,
[reseller_uuid] [binary] (16) NULL,
[reseller_address] [nvarchar] (255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[total_amount] [float] NULL,
[total_tax_amount] [float] NULL,
[sub_total_amount] [float] NULL,
[currency_type_id] [varchar] (3) COLLATE SQL_Latin1_General_CP1_CS_AS NULL,
[assets_created] [int] NULL CONSTRAINT [DF__al_purcha__asset__2EDD5856] DEFAULT ('0'),
[purchase_order_status_id] [int] NOT 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__al_purcha__versi__2FD17C8F] DEFAULT ('0'),
[buyer_contact_uuid] [binary] (16) NULL,
[terms] [nvarchar] (2000) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[date_required] [datetime] NULL,
[shipment_type_id] [int] NULL,
[billing_company_uuid] [binary] (16) NULL
) ON [PRIMARY]

GO
CREATE TRIGGER al_c_purchordr_tr ON dbo.al_purchase_order
AFTER INSERT
AS
BEGIN

    DECLARE @purchaseorderid int
    DECLARE @creationuser nvarchar(255)
    DECLARE @creationdate int
    DECLARE @lastupdateuser nvarchar(255)
    DECLARE @lastupdatedate int

    SELECT  @purchaseorderid = purchase_order_id,
            @creationuser = creation_user,
            @creationdate = creation_date,
            @lastupdateuser = last_update_user,
            @lastupdatedate = last_update_date
    FROM INSERTED

    INSERT INTO al_purchase_order_flags
    (purchase_order_id, from_uapm, creation_user, creation_date, last_update_user, last_update_date,  version_number)
    VALUES
    (@purchaseorderid, 0, @creationuser,@creationdate, @lastupdateuser, @lastupdatedate, 0)
END
GO
CREATE TRIGGER al_d_purchordr_tr ON dbo.al_purchase_order
INSTEAD OF DELETE
AS
BEGIN

    DECLARE @purchaseorderid int

    SELECT  @purchaseorderid = purchase_order_id
    FROM DELETED

    DELETE FROM al_purchase_order_flags WHERE purchase_order_id = @purchaseorderid
    DELETE FROM al_purchase_order WHERE purchase_order_id = @purchaseorderid
END
GO
ALTER TABLE [dbo].[al_purchase_order] ADD CONSTRAINT [PK_al_purchase_order] PRIMARY KEY CLUSTERED ([purchase_order_id]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[al_purchase_order] ADD CONSTRAINT [AL_PURCHASE_ORDER_FK01] FOREIGN KEY ([currency_type_id]) REFERENCES [dbo].[ca_currency_type] ([currency_type_code])
GO
ALTER TABLE [dbo].[al_purchase_order] ADD CONSTRAINT [AL_PURCHASE_ORDER_FK02] FOREIGN KEY ([purchase_order_status_id]) REFERENCES [dbo].[al_purchase_order_status] ([id])
GO
ALTER TABLE [dbo].[al_purchase_order] ADD CONSTRAINT [AL_PURCHASE_ORDER_FK03] FOREIGN KEY ([ship_to_contact_uuid]) REFERENCES [dbo].[ca_contact] ([contact_uuid])
GO
ALTER TABLE [dbo].[al_purchase_order] ADD CONSTRAINT [AL_PURCHASE_ORDER_FK04] FOREIGN KEY ([billing_location_uuid]) REFERENCES [dbo].[ca_location] ([location_uuid])
GO
ALTER TABLE [dbo].[al_purchase_order] ADD CONSTRAINT [AL_PURCHASE_ORDER_FK05] FOREIGN KEY ([reseller_uuid]) REFERENCES [dbo].[ca_company] ([company_uuid])
GO
ALTER TABLE [dbo].[al_purchase_order] ADD CONSTRAINT [AL_PURCHASE_ORDER_FK07] FOREIGN KEY ([buyer_contact_uuid]) REFERENCES [dbo].[ca_contact] ([contact_uuid])
GO
ALTER TABLE [dbo].[al_purchase_order] ADD CONSTRAINT [AL_PURCHASE_ORDER_FK08] FOREIGN KEY ([billing_company_uuid]) REFERENCES [dbo].[ca_company] ([company_uuid])
GO
ALTER TABLE [dbo].[al_purchase_order] ADD CONSTRAINT [AL_PURCHASE_ORDER_FK09] FOREIGN KEY ([shipment_type_id]) REFERENCES [dbo].[al_shipment_type] ([id])
GO
GRANT SELECT ON  [dbo].[al_purchase_order] TO [swcmadmin]
GRANT INSERT ON  [dbo].[al_purchase_order] TO [swcmadmin]
GRANT DELETE ON  [dbo].[al_purchase_order] TO [swcmadmin]
GRANT UPDATE ON  [dbo].[al_purchase_order] TO [swcmadmin]
GO
Uses
Used By