Trigger nesting level exceeded?

2019-08-07 23:56发布

When this trigger fires, which is contained in the below code block

alter TRIGGER [dbo].[locations_update_geometry_After]
ON  dbo.TBL_LOCATIONS   
for update   
AS   
  INSERT dbo.TBL_LOCATIONS(SHAPE, X_Coord, Y_Coord,objectid) 
  SELECT a.Shape, a.X_Coord, a.Y_Coord, a.objectid
  FROM  
  (  
    SELECT  
      SHAPE = CASE WHEN SHAPE IS NOT NULL   
        THEN SHAPE ELSE Geometry::STPointFromText('POINT('  
          + CAST(X_Coord AS VARCHAR(20)) + ' '   
          + CAST(Y_Coord AS VARCHAR(20)) + ')', 26917) END,  
      X_Coord = CASE WHEN SHAPE IS NULL THEN X_Coord ELSE SHAPE.STX END,  
      Y_Coord = CASE WHEN SHAPE IS NULL THEN Y_Coord ELSE SHAPE.STY END,  
      objectid  
     FROM inserted  
  ) AS a

I get the following error message:

Unable to save edits. Underlying DBMS error [Microsoft SQL Server Native Client 10: Maximum stored procedure, function, trigger, or view nesting level exceeded (limit 32).

I do not have 32 of anything associated with this table. any ideas?

2条回答
爱情/是我丢掉的垃圾
2楼-- · 2019-08-08 00:08

Yes, trigger executes for 32 times before throwing a message; in order to stop doing that use this

IF ((
SELECT TRIGGER_NESTLEVEL()) > 1 )
RETURN
查看更多
混吃等死
3楼-- · 2019-08-08 00:26
登录 后发表回答