Back to OIM Explorer

dbo.ATT_ZAttestationMakeDecisionWC

Stored ProcedureSQL_STORED_PROCEDURESandbox DB

Stored Procedure. HOCallMethod -> AttestationCase.MakeDecision at line 56; References QBM_PJobCreate*; References QBM_PJobCreate_HOCallMethod*

Source: sandbox-db sys.sql_modules

Source size: 4.778 characters

Interpretation

  • Database routine. Review parameters, called procedures, DBQueue inserts, and QBM_PJobCreate helper calls before assuming side effects.
  • Object-layer bridge detected through QBM_PJobCreate helper usage.

Relations

  • HOCallMethod -> AttestationCase.MakeDecision at line 56
  • References QBM_PJobCreate*
  • References QBM_PJobCreate_HOCallMethod*

Typed Edges

  • calls object method AttestationCase.MakeDecision HOCallMethod -> AttestationCase.MakeDecision at line 56
  • references source dbo.QBM_FGIDBQueueSlotResetType source text reference
  • references source dbo.QBM_PDBQCS_CurrentMoveSlot source text reference
  • references source dbo.QBM_PJobCreate source text reference
  • references source dbo.QBM_PJobCreate_HOCallMethod source text reference
  • references source dbo.QBM_PJournal source text reference
  • references source dbo.QBM_PSessionErrorAdd source text reference

Complete Source

SQL209 lines
1CREATE PROCEDURE ATT_ZAttestationMakeDecisionWC(2  @SlotNumber int3)4AS5BEGIN6  DECLARE @UID_AttestationCase varchar(38)7  DECLARE @GenProcID varchar(38)8  DECLARE @Decision nvarchar(16)9  DECLARE @Reason nvarchar(255)10  DECLARE @uid_person varchar(38)11  DECLARE @cond nvarchar(max)12  DECLARE @whereclause nvarchar(max)13  DECLARE @SQLcmd nvarchar(max)14  DECLARE @muster nvarchar(max)15  DECLARE @CountItems int16  DECLARE @AutomaticReasonTrue nvarchar(128)17  DECLARE @AutomaticReasonFalse nvarchar(128)18  DECLARE @BasisObjectKey varchar(138)19  DECLARE @DecisionLevel int20  DECLARE @DebugLevel char(1) = 'W'21  DECLARE @ElementBuffer QBM_YCursorBuffer22  DECLARE @ElementCount int23  DECLARE @ElementIndex int24  DECLARE @SQLCmdWithRetry nvarchar(max)25  DECLARE @ErrorBuffer QBM_YSessionError26  DECLARE @SlotNumberSource int27  DECLARE @SlotNumberTarget int28  DECLARE @DBQueueToMove QBM_YDBQCSCurrentToMove29  DECLARE @RowsMoved int30  SET XACT_ABORT OFF31  BEGIN TRY32    SELECT33      @muster = '34declare @erg int35select @erg = 36-- die Kundenklausel37@whereclause (''@UID_AttestationCase'')3839--print @erg4041if @erg > 042 begin43	select 144	 union all 45	select 246	 union all 47	select 348	 49 end50else --bleiben noch 0 und < 051 begin52	 if @erg < 053	  begin54		select 155	  end56	 else -- ist es gleich 057	  begin58		select 159		 union all60		select 261	  end62 end63		64'65    INSERT INTO @ElementBuffer(UID1,66    UID2,67    ContentFull,68    LongIdent1,69    LongIdent2,70    ObjectKey1,71    Int1)72    SELECT73      ac.UID_AttestationCase,74      p.GenprocID,75      isnull(ds.WhereClause,76      N ''),77      isnull(ds.AutomaticReasonTrue,78      ''),79      isnull(ds.AutomaticReasonFalse,80      ''),81      ac.XObjectKey,82      ac.DecisionLevel83    FROM QBMDBQueueCurrent p84      WITH(readpast)85    JOIN AttestationCase ac86      ON p.uid_parameter = ac.UID_AttestationCase87    JOIN AttestationHelper ah88      ON ac.UID_AttestationCase = ah.UID_AttestationCase AND ac.decisionlevel = ah.levelnumber89    JOIN QERWorkingStep ds90      ON ah.UID_QERWorkingStep = ds.UID_QERWorkingStep91    WHERE92      ah.UID_PWODecisionRule = 'ATT-PWODecisionRule-WC' AND isnull(ac.isclosed,93    0) = 0 AND p.SlotNumber = @SlotNumber94    SELECT @ElementCount = @@ROWCOUNT95    SELECT @ElementIndex = 196    WHILE @ElementIndex <= @ElementCount97    BEGIN98      SELECT99        TOP 1 @UID_AttestationCase = bu.UID1,100        @GenProcID = bu.UID2,101        @whereclause = bu.ContentFull,102        @AutomaticReasonTrue = bu.LongIdent1,103        @AutomaticReasonFalse = bu.LongIdent2,104        @BasisObjectKey = bu.ObjectKey1,105        @DecisionLevel = bu.Int1106      FROM @ElementBuffer bu107      WHERE108        bu.ElementIndex = @ElementIndex109      SELECT @SQLcmd = @muster110      SELECT111        @SQLcmd = replace(@SQLcmd,112        N '@whereclause',113        @whereclause)114      SELECT115        @SQLcmd = replace(@SQLcmd,116        N '@UID_AttestationCase',117        @UID_AttestationCase)118      BEGIN TRY119        EXEC sp_executesql @SQLcmd120        SELECT @CountItems = @@rowcount121      END TRY122      BEGIN CATCH123        SELECT @CountItems = -1124      END CATCH125      IF @CountItems = 3126      BEGIN127        SELECT @decision = 'True'128        IF @AutomaticReasonTrue > ' '129        BEGIN130          SELECT @Reason = @AutomaticReasonTrue131        END132        ELSE133        BEGIN134          SELECT @reason = '#LDS#Automatic system approval with method WC: Condition was met.|'135        END136      END137      IF @CountItems = 1138      BEGIN139        SELECT @decision = 'False'140        IF @AutomaticReasonFalse > ' '141        BEGIN142          SELECT @Reason = @AutomaticReasonFalse143        END144        ELSE145        BEGIN146          SELECT147            @reason = '#LDS#Automatic system approval with method WC: Condition was not met.|'148        END149      END150      IF @CountItems = 2151      BEGIN152        DELETE @DBQueueToMove153        INSERT INTO @DBQueueToMove(UID_DialogDBQueue)154        SELECT cul.UID_DialogDBQueue155        FROM QBMDBQueueCurrent cul156        WHERE157          cul.SlotNumber = @SlotNumber AND cul.UID_Parameter = @UID_AttestationCase158        IF @@ROWCOUNT > 0159        BEGIN160          SELECT @SlotNumberSource = @SlotNumber161          SELECT @SlotnumberTarget = dbo.QBM_FGIDBQueueSlotResetType('Wait')162          EXEC @RowsMoved = QBM_PDBQCS_CurrentMoveSlot @DBQueueToMove,163            @SlotNumberSource,164            @SlotnumberTarget165          EXEC QBM_PJournal '#LDS#Deferring operations resulting form the IT Shop procedure "waiting for condition".|',166            @@procid,167          'I',168            @DebugLevel169        END170      END171      IF @CountItems < 0172      BEGIN173        SELECT @decision = 'False'174        SELECT175          @reason = '#LDS#Automatic system approval: Condition caused runtime error using method WC.|'176      END177      IF @CountItems = 3 OR @CountItems = 1 OR @CountItems < 0178      BEGIN179        SELECT180          @cond = N 'UID_AttestationCase = ''' + rtrim(@UID_AttestationCase) + N ''' and DecisionLevel = ' + STR(@DecisionLevel)181        EXEC QBM_PJobCreate_HOCallMethod @objecttype = 'AttestationCase',182          @whereclause = @cond,183          @save = 1,184          @MethodName = 'MakeDecision',185          @GenProcID = @GenprocID,186          @ObjectKeysAffected = DEFAULT,187          @param1 = 'sa',188          @param2 = @decision,189          @param3 = @reason,190          @Retries = 3,191          @isToFreezeOnError = 1,192          @BasisObjectKey = @BasisObjectKey,193          @checkForExisting = 1,194          @WhereClauseAdditional = ' IsClosed = 0 '195      END196      SELECT @ElementIndex += 1197    END198  END TRY199  BEGIN CATCH200    EXEC QBM_PSessionErrorAdd DEFAULT,201      @SQLCmdWithRetry202    RAISERROR('',203    18,204    1)205      WITH nowait206  END CATCH207  endLabel:208  RETURN209END
Open raw exported source
SQL ยท Raw60 lines
1  create   procedure ATT_ZAttestationMakeDecisionWC (@SlotNumber int) as begin  declare @UID_AttestationCase varchar(38) declare @GenProcID varchar2(38) declare @Decision nvarchar(16) declare @Reason nvarchar(255) declare @uid_person varchar(38) declare @cond nvarchar(max) declare @whereclause nvarchar3(max) declare @SQLcmd nvarchar(max) declare @muster nvarchar(max) declare @CountItems int declare @AutomaticReasonTrue nvarchar(128) declare @AutomaticReasonFalse4 nvarchar(128) declare @BasisObjectKey varchar(138) declare @DecisionLevel int declare @DebugLevel char(1) = 'W' declare @ElementBuffer QBM_YCursorBuffer5 declare @ElementCount int declare @ElementIndex int declare @SQLCmdWithRetry nvarchar(max) declare @ErrorBuffer QBM_YSessionError declare @SlotNumberSource6 int declare @SlotNumberTarget int declare @DBQueueToMove QBM_YDBQCSCurrentToMove declare @RowsMoved int SET XACT_ABORT OFF BEGIN TRY  select @muster =7 '8declare @erg int9select @erg = 10-- die Kundenklausel11@whereclause (''@UID_AttestationCase'')1213--print @erg1415if @erg > 016 begin17	select 118	 union all 19	select 220	 union all 21	select 322	 23 end24else --bleiben noch 0 und < 025 begin26	 if @erg < 027	  begin28		select 129	  end30	 else -- ist es gleich 031	  begin32		select 133		 union all34		select 235	  end36 end37		38'39 insert into @ElementBuffer ( UID1  , UID2  , ContentFull  , LongIdent1  , LongIdent2  , ObjectKey1  , Int1  ) select ac.UID_AttestationCase , p.GenprocID40, isnull(ds.WhereClause, N'') , isnull(ds.AutomaticReasonTrue, ''), isnull(ds.AutomaticReasonFalse, ''), ac.XObjectKey , ac.DecisionLevel from QBMDBQueueCurrent41 p with (readpast) join AttestationCase ac on p.uid_parameter = ac.UID_AttestationCase join AttestationHelper ah on ac.UID_AttestationCase = ah.UID_AttestationCase42 and ac.decisionlevel = ah.levelnumber join QERWorkingStep ds on ah.UID_QERWorkingStep = ds.UID_QERWorkingStep  where ah.UID_PWODecisionRule = 'ATT-PWODecisionRule-WC'43 and isnull(ac.isclosed,0) = 0 and p.SlotNumber = @SlotNumber select @ElementCount = @@ROWCOUNT select @ElementIndex = 1 while @ElementIndex <= @ElementCount44 begin select top 1 @UID_AttestationCase = bu.UID1  , @GenProcID = bu.UID2  , @whereclause = bu.ContentFull  , @AutomaticReasonTrue = bu.LongIdent1  , 45@AutomaticReasonFalse = bu.LongIdent2  , @BasisObjectKey = bu.ObjectKey1  , @DecisionLevel = bu.Int1  from @ElementBuffer bu where bu.ElementIndex = @ElementIndex46 select @SQLcmd = @muster select @SQLcmd = replace(@SQLcmd , N'@whereclause', @whereclause) select @SQLcmd = replace(@SQLcmd, N'@UID_AttestationCase', 47@UID_AttestationCase)  BEGIN TRY exec sp_executesql @SQLcmd select @CountItems = @@rowcount END TRY BEGIN CATCH select @CountItems = -1 END CATCH if @CountItems48 = 3  begin  select @decision = 'True'  if @AutomaticReasonTrue > ' ' begin select @Reason = @AutomaticReasonTrue end else begin select @reason = '#LDS#Automatic system approval with method WC: Condition was met.|'49 end end if @CountItems = 1  begin select @decision = 'False'  if @AutomaticReasonFalse > ' ' begin select @Reason = @AutomaticReasonFalse end else begin50 select @reason = '#LDS#Automatic system approval with method WC: Condition was not met.|' end end if @CountItems = 2  begin  delete @DBQueueToMove  insert51 into @DBQueueToMove(UID_DialogDBQueue) select cul.UID_DialogDBQueue from QBMDBQueueCurrent cul  where cul.SlotNumber = @SlotNumber and cul.UID_Parameter52 = @UID_AttestationCase if @@ROWCOUNT > 0 begin select @SlotNumberSource = @SlotNumber  select @SlotnumberTarget = dbo.QBM_FGIDBQueueSlotResetType('Wait'53) exec @RowsMoved = QBM_PDBQCS_CurrentMoveSlot @DBQueueToMove, @SlotNumberSource, @SlotnumberTarget exec QBM_PJournal '#LDS#Deferring operations resulting form the IT Shop procedure "waiting for condition".|'54, @@procid, 'I', @DebugLevel end end if @CountItems < 0  begin select @decision = 'False' select @reason = '#LDS#Automatic system approval: Condition caused runtime error using method WC.|'55 end if @CountItems = 3 or @CountItems = 1 or @CountItems < 0 begin select @cond = N'UID_AttestationCase = ''' + rtrim(@UID_AttestationCase) + N''' and DecisionLevel = '56 + STR(@DecisionLevel)  exec QBM_PJobCreate_HOCallMethod @objecttype = 'AttestationCase' , @whereclause = @cond , @save = 1 , @MethodName = 'MakeDecision'57 , @GenProcID = @GenprocID , @ObjectKeysAffected = DEFAULT , @param1 = 'sa' , @param2 = @decision , @param3 = @reason , @Retries = 3 , @isToFreezeOnError58 = 1  , @BasisObjectKey = @BasisObjectKey , @checkForExisting = 1 , @WhereClauseAdditional = ' IsClosed = 0 '  end select @ElementIndex += 1 end  END TRY59 BEGIN CATCH exec QBM_PSessionErrorAdd default, @SQLCmdWithRetry raiserror ('', 18, 1) with nowait END CATCH endLabel: return end 60