Table of Contents



pears.SalesBrand

Generated schema reference. Regenerate this page from the SQL unload; keep hand-maintained business notes in the narrative namespace.

Columns

Column Type Null Default Comment
SalesBrandID char(20) NOT NULL
DivisionID char(20) NULL
InvoicePrefix char(10) NULL
Description char(50) NOT NULL
Analysis char(50) NULL
AlternativeInvoiceAddressEmailID char(20) NULL may not be used
InvoiceEmail char(250) NULL may not be used
InvoiceAddress long varchar NULL may not be used
Defunct tinyint NOT NULL 0

Primary Key

Foreign Keys

Constraint Columns References Delete/update action
Division DivisionID pears.Division (divisionid) ON DELETE CASCADE
AlternativeInvoiceAddressEmail AlternativeInvoiceAddressEmailID pears.AlternativeInvoiceAddressEmail (AlternativeInvoiceAddressEmailID) ON DELETE CASCADE

Referenced By

Table Constraint Columns Referenced columns
pears.AccountOverrideInvoiceAddress SalesBrand SalesBrandID SalesBrandID
pears.Placement SalesBrand SalesBrandID SalesBrandID

Indexes

Triggers

Name Timing Event
SalesBrandAudit after update of “InvoiceEmail”, “InvoiceAddress”,“InvoicePrefix” order 1

Original SQL

-- IQX database structure split by table
-- Source: IQXDatabaseStructure - with comments.sql
-- Table: "pears"."SalesBrand"
-- Table comment: 
-- Statement count: 8
 
CREATE TABLE "pears"."SalesBrand" (
    "SalesBrandID"                   CHAR(20) NOT NULL
   ,"DivisionID"                     CHAR(20) NULL
   ,"InvoicePrefix"                  CHAR(10) NULL
   ,"Description"                    CHAR(50) NOT NULL
   ,"Analysis"                       CHAR(50) NULL
   ,"AlternativeInvoiceAddressEmailID" CHAR(20) NULL
   ,"InvoiceEmail"                   CHAR(250) NULL
   ,"InvoiceAddress"                 long VARCHAR NULL
   ,"Defunct"                        tinyint NOT NULL DEFAULT 0
   ,PRIMARY KEY ("SalesBrandID" ASC) 
)
GO
 
 
COMMENT ON COLUMN "pears"."SalesBrand"."AlternativeInvoiceAddressEmailID" IS 
	'may not be used'
GO
 
 
COMMENT ON COLUMN "pears"."SalesBrand"."InvoiceEmail" IS 
	'may not be used'
GO
 
 
COMMENT ON COLUMN "pears"."SalesBrand"."InvoiceAddress" IS 
	'may not be used'
GO
 
 
ALTER TABLE "pears"."SalesBrand"
    ADD FOREIGN KEY "Division" ("DivisionID" ASC)
    REFERENCES "pears"."Division" ("divisionid")
    ON DELETE CASCADE
GO
 
 
ALTER TABLE "pears"."SalesBrand"
    ADD FOREIGN KEY "AlternativeInvoiceAddressEmail" ("AlternativeInvoiceAddressEmailID" ASC)
    REFERENCES "pears"."AlternativeInvoiceAddressEmail" ("AlternativeInvoiceAddressEmailID")
    ON DELETE CASCADE
GO
 
 
CREATE TRIGGER "SalesBrandAudit" after UPDATE OF "InvoiceEmail",
"InvoiceAddress","InvoicePrefix" ORDER 1 ON
"pears"."SalesBrand"
REFERENCING OLD AS "old_brand" NEW AS "new_brand"
FOR each ROW
BEGIN
  IF UPDATE("InvoiceEmail") THEN
    CALL "AuditLog"('SALESBRAND',"new_brand"."SalesBrandID","string"("new_brand"."description",' - Email'),"old_brand"."InvoiceEmail","new_brand"."InvoiceEmail")
  ELSE IF UPDATE("InvoiceAddress") THEN
      CALL "AuditLog"('SALESBRAND',"new_brand"."SalesBrandID","string"("new_brand"."description",' - Address'),"old_brand"."InvoiceAddress","new_brand"."InvoiceAddress")
    ELSE IF UPDATE("InvoicePrefix") THEN
        CALL "AuditLog"('SALESBRAND',"new_brand"."SalesBrandID","string"("new_brand"."description",' - Prefix'),"old_brand"."InvoicePrefix","new_brand"."InvoicePrefix")
      END IF END IF END IF
END
GO
 
 
COMMENT TO PRESERVE FORMAT ON TRIGGER "pears"."SalesBrand"."SalesBrandAudit" IS 
{CREATE TRIGGER SalesBrandAudit 
 after UPDATE OF InvoiceEmail,InvoiceAddress,InvoicePrefix  ORDER 1 ON
SalesBrand
REFERENCING OLD AS old_brand NEW AS new_brand
FOR each ROW
BEGIN
   IF UPDATE  (InvoiceEmail) THEN   
    CALL AuditLog('SALESBRAND',new_brand.SalesBrandID,string(new_brand.description ,' - Email'),old_brand.InvoiceEmail,new_brand.InvoiceEmail)
   ELSE IF UPDATE  (InvoiceAddress) THEN 
    CALL AuditLog('SALESBRAND',new_brand.SalesBrandID,string(new_brand.description ,' - Address'),old_brand.InvoiceAddress,new_brand.InvoiceAddress)
   ELSE IF UPDATE  (InvoicePrefix) THEN  
    CALL AuditLog('SALESBRAND',new_brand.SalesBrandID,string(new_brand.description ,' - Prefix'),old_brand.InvoicePrefix,new_brand.InvoicePrefix)
   END IF END IF END IF;
END
}
GO