====== pears.TSQueryHistory ====== Generated schema reference. Regenerate this page from the SQL unload; keep hand-maintained business notes in the narrative namespace. ===== Description ===== Record of changes to Timesheet Queries ===== Columns ===== ^ Column ^ Type ^ Null ^ Default ^ Comment ^ | **TSQueryHistoryID** | char(20) | NOT NULL | | | | TSQueryLogID | char(20) | NOT NULL | | | | WhenEntered | timestamp | NULL | current timestamp | | | WhoEntered | char(20) | NULL | | | | Notes | long varchar | NULL | | | | OldStatus | char(1) | NULL | | | | NewStatus | char(1) | NULL | | | ===== Primary Key ===== * TSQueryHistoryID ===== Foreign Keys ===== ^ Constraint ^ Columns ^ References ^ Delete/update action ^ | TSQueryLog | TSQueryLogID | [[database:tables:pears_tsquerylog|pears.TSQueryLog (TSQueryLogID)]] | NOT NULL; | ===== Referenced By ===== * No incoming foreign keys found. ===== Indexes ===== * No indexes found. ===== Triggers ===== ^ Name ^ Timing ^ Event ^ | TSQueryHistoryinsert | before | insert order 1 | ===== Original SQL ===== -- IQX database structure split by table -- Source: IQXDatabaseStructure - with comments.sql -- Table: "pears"."TSQueryHistory" -- Table comment: Record of changes to Timesheet Queries -- Statement count: 5 CREATE TABLE "pears"."TSQueryHistory" ( "TSQueryHistoryID" char(20) NOT NULL ,"TSQueryLogID" char(20) NOT NULL ,"WhenEntered" timestamp NULL DEFAULT current timestamp ,"WhoEntered" char(20) NULL ,"Notes" long varchar NULL ,"OldStatus" char(1) NULL ,"NewStatus" char(1) NULL ,PRIMARY KEY ("TSQueryHistoryID" ASC) ) go COMMENT ON TABLE "pears"."TSQueryHistory" IS 'Record of changes to Timesheet Queries' go ALTER TABLE "pears"."TSQueryHistory" ADD NOT NULL FOREIGN KEY "TSQueryLog" ("TSQueryLogID" ASC) REFERENCES "pears"."TSQueryLog" ("TSQueryLogID") go create trigger "TSQueryHistoryinsert" before insert order 1 on "pears"."TSQueryHistory" referencing new as "new_tsq" for each row when("new_tsq"."WhoEntered" is null) begin set "new_tsq"."WhoEntered" = "userstaffid" exception when others then set "new_tsq"."WhoEntered" = null end go COMMENT TO PRESERVE FORMAT ON TRIGGER "pears"."TSQueryHistory"."TSQueryHistoryinsert" IS {create trigger TSQueryHistoryinsert before insert order 1 on pears.TSQueryHistory referencing new as new_tsq for each row when(new_tsq.WhoEntered is null) begin set new_tsq.WhoEntered=userstaffid exception when others then set new_tsq.WhoEntered=null end } go