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 |
| PersonShiftPreferenceID | char(20) | NOT NULL | | |
| personid | char(20) | NOT NULL | | |
| TempShiftTemplateID | char(20) | NULL | | |
| companyid | char(20) | NULL | | |
| WhenEntered | timestamp | NOT NULL | current timestamp | |
| WhoEntered | char(20) | NULL | | |
| Name | Timing | Event |
| PersonShiftPreference_Insert | before | insert order 1 |
-- IQX database structure split by table
-- Source: IQXDatabaseStructure - with comments.sql
-- Table: "pears"."PersonShiftPreference"
-- Table comment:
-- Statement count: 6
CREATE TABLE "pears"."PersonShiftPreference" (
"PersonShiftPreferenceID" CHAR(20) NOT NULL
,"personid" CHAR(20) NOT NULL
,"TempShiftTemplateID" CHAR(20) NULL
,"companyid" CHAR(20) NULL
,"WhenEntered" TIMESTAMP NOT NULL DEFAULT CURRENT TIMESTAMP
,"WhoEntered" CHAR(20) NULL
,PRIMARY KEY ("PersonShiftPreferenceID" ASC)
)
GO
ALTER TABLE "pears"."PersonShiftPreference"
ADD NOT NULL FOREIGN KEY "Person" ("personid" ASC)
REFERENCES "pears"."Person" ("personid")
ON DELETE CASCADE
GO
ALTER TABLE "pears"."PersonShiftPreference"
ADD FOREIGN KEY "TempShiftTemplate" ("TempShiftTemplateID" ASC)
REFERENCES "pears"."TempShiftTemplate" ("TempShiftTemplateID")
ON DELETE CASCADE
GO
ALTER TABLE "pears"."PersonShiftPreference"
ADD FOREIGN KEY "Company" ("companyid" ASC)
REFERENCES "pears"."Company" ("companyid")
ON DELETE CASCADE
GO
CREATE TRIGGER "PersonShiftPreference_Insert" BEFORE INSERT ORDER 1 ON
"pears"."PersonShiftPreference"
REFERENCING NEW AS "new_psp"
FOR each ROW
WHEN("new_psp"."whoentered" IS NULL)
BEGIN
SET "new_psp"."whoentered" = "userstaffid"
exception
WHEN others THEN
SET "new_psp"."whoentered" = NULL
END
GO
COMMENT TO PRESERVE FORMAT ON TRIGGER "pears"."PersonShiftPreference"."PersonShiftPreference_Insert" IS
{CREATE TRIGGER PersonShiftPreference_Insert
BEFORE INSERT ORDER 1 ON
pears.PersonShiftPreference
REFERENCING NEW AS new_psp
FOR each ROW
WHEN(new_psp.whoentered IS NULL)
BEGIN
SET new_psp.whoentered=userstaffid
exception
WHEN others THEN
SET new_psp.whoentered=NULL
END
}
GO