Sample Header Ad - 728x90

ORDER placement for trigger in t-sql

0 votes
2 answers
174 views
I'm using Sybase ASE version 16.0.0.1915, (follows t-sql syntax) and trying to create a new trigger. This new trigger emulates another existing trigger, however is slightly modified. It would be a whole lot harder to modify the existing trigger to address both "workflows", so copying into a new trigger with modified details and an order of "2" would be my preferred solution. I'm reading in the docs, that in order to create a new trigger based on the same action, I need to set the order for the triggers to fire off. If no order is specified, it is assigned order of 0 (first). Docs So here is my trigger, the existing similar trigger does not have an order set. When I place "ORDER 2" into the create statement (after the name, before "on" in row 1), I keep getting syntax error -131. I've also tried placing the "ORDER 2" after the table name, before "for", and after "insert", before "as". All producing the same error -131. So what am I doing wrong? Is there some other problem with this trigger preventing me to use the ORDER clause? create trigger "DBA"."WKM_autoFillCL143" on "DBA"."case_checklist" for insert as if((select top 1 "inserted"."code" from "inserted") in( '143' ) ) begin declare @parentRef integer,@desc varchar(255),@desc1 varchar(255),@checkID integer set @parentRef = (select top 1 "parent_ref" from "inserted") if(@parentRef '0') begin set @desc = (select "description" from "case_checklist" where "checklist_id" = @parentRef) if(@desc is not null) begin set @checkID = (select top 1 "checklist_id" from "inserted") update "WKM_RecordChecklistMapping" set "c143" = @checkID where "c142" = @parentRef declare @tabid integer set @tabid = (select top 1 "tab_id" from "WKM_recordChecklistMapping" where "c142" = @parentRef) set @tabid = (select top 1 "tab_id" from "user_tab2_data" where "tab_id" = @tabid) if(@tabid is not null) begin declare @recProvider varchar(255),@recsRequested varchar(255),@dateFrom "datetime",@dateTo "datetime" set @recProvider = (select top 1 "Provider_Name" from "user_tab2_data" where "tab_id" = @tabid) set @recsRequested = (select top 1 "Records_Requested" from "user_tab2_data" where "tab_id" = @tabid) set @dateFrom = (select top 1 "For_Dates_From" from "user_tab2_data" where "tab_id" = @tabid) set @dateTo = (select top 1 "Through" from "user_tab2_data" where "tab_id" = @tabid) set @desc1 = 'Receipt '+@recProvider+' Records? '+@recsRequested+', dates '+"coalesce"(convert(varchar(255),@dateFrom,1),'00/00/00')+' to '+"coalesce"(convert(varchar(255),@dateTo,1),'00/00/00') set @checkID = (select top 1 "checklist_id" from "inserted") update "case_checklist" set "description" = @desc1,"staff_assigned" = 'ZKS',"due_date" = ("today"()+7) where "checklist_id" = @checkID end end end end
Asked by boog (153 rep)
Jan 7, 2021, 09:44 PM
Last activity: Jan 13, 2021, 04:28 PM