Back to OIM Explorer

dbo.QER_PQERRiskIndexDefine

Stored ProcedureSQL_STORED_PROCEDURESandbox DB

Stored Procedure.

Source: sandbox-db sys.sql_modules

Source size: 2.321 characters

Interpretation

  • Database routine. Review parameters, called procedures, DBQueue inserts, and QBM_PJobCreate helper calls before assuming side effects.

Relations

  • No extracted relations.

Typed Edges

  • references source dbo.QBM_FCVElementToObjectKey1 source text reference
  • references source dbo.QBM_FCVGuidToTransfer source text reference
  • references source dbo.QBM_FGIDBOwner source text reference
  • references source dbo.QBM_FGISessionErrorRethrow source text reference
  • references source dbo.QBM_PSessionErrorAdd source text reference

Complete Source

SQL114 lines
1CREATE PROCEDURE QER_PQERRiskIndexDefine(2  @TableName varchar(30),3  @ColumnName varchar(30),4  @TypeOfCalculation varchar(3),5  @Weight float,6  @QueryString nvarchar(max),7  @DisplayValue nvarchar(64),8  @Description nvarchar(max),9  @IsInActive BIT = 0,10  @UID_QERRiskIndex varchar(38) = NULL11)12AS13BEGIN14  DECLARE @UID_DialogColumn varchar(38)15  DECLARE @IsInsert BIT = 016  DECLARE @Xdate datetime = getutcdate()17  DECLARE @XUser nvarchar(64) = object_name(@@procid)18  DECLARE @Msg nvarchar(1000)19  SET XACT_ABORT OFF20  BEGIN TRY21    SELECT TOP 1 @UID_DialogColumn = c.UID_DialogColumn22    FROM DialogTable t23      WITH(readpast)24    JOIN DialogColumn c25      WITH(readpast)26      ON t.UID_DialogTable = c.UID_DialogTable27    WHERE28      c.ColumnName = @ColumnName AND t.TableName = @TableName29    IF @UID_DialogColumn IS NULL30    BEGIN31      SELECT32        @Msg = '#LDS#Column {0} not found in table {1}.|' + @ColumnName + '|' + @TableName + '|'33      RAISERROR(@msg,34      18,35      1)36        WITH nowait37    END38    IF @UID_QERRiskIndex IS NULL39    BEGIN40      SELECT TOP 1 @UID_QERRiskIndex41      FROM QERRiskIndex r42      WHERE43        r.UID_DialogColumn = @UID_DialogColumn AND r.DisplayValue = @DisplayValue AND r.TypeOfCalculation = @TypeOfCalculation44    END45    IF @UID_QERRiskIndex IS NULL46    BEGIN47      SELECT48        @UID_QERRiskIndex = dbo.QBM_FCVGuidToTransfer(newid(),49        dbo.QBM_FGIDBOwner())50    END51    IF NOT EXISTS(52      SELECT TOP 1 153      FROM QERRiskIndex r54      WHERE55        r.UID_QERRiskIndex = @UID_QERRiskIndex)56    BEGIN57      SELECT @IsInsert = 158    END59    IF @IsInsert = 160    BEGIN61      INSERT INTO QERRiskIndex(Description,62      DisplayValue,63      IsInActive,64      QueryString,65      TypeOfCalculation,66      UID_DialogColumn,67      UID_QERRiskIndex,68      Weight,69      XDateInserted,70      XDateUpdated,71      XUserInserted,72      XUserUpdated,73      XObjectKey)74      SELECT75        @Description,76        @DisplayValue,77        @IsInActive,78        @QueryString,79        @TypeOfCalculation,80        @UID_DialogColumn,81        @UID_QERRiskIndex,82        @Weight,83        @XDate,84        @Xdate,85        @XUser,86        @XUser,87        dbo.QBM_FCVElementToObjectKey1('QERRiskIndex',88        'UID_QERRiskIndex',89        @UID_QERRiskIndex)90    END91    ELSE92    BEGIN93      UPDATE QERRiskIndex94      SET Description = @Description,95      IsInActive = @IsInActive,96      QueryString = @QueryString,97      Weight = @Weight,98      XDateUpdated = @Xdate,99      XUserUpdated = @XUser100      WHERE101        UID_QERRiskIndex = @UID_QERRiskIndex102    END103  END TRY104  BEGIN CATCH105    EXEC QBM_PSessionErrorAdd DEFAULT106    DECLARE @Rethrow varchar(1000) = dbo.QBM_FGISessionErrorRethrow()107    RAISERROR(@Rethrow,108    18,109    1)110      WITH NOWAIT111  END CATCH112  ende:113  RETURN114END
Open raw exported source
SQL ยท Raw16 lines
1  create   procedure QER_PQERRiskIndexDefine( @TableName varchar(30) , @ColumnName varchar(30) , @TypeOfCalculation varchar(3) , @Weight float ,2 @QueryString nvarchar(max) , @DisplayValue nvarchar(64) , @Description nvarchar(max) , @IsInActive bit = 0 , @UID_QERRiskIndex varchar(38) = null ) as3 begin declare @UID_DialogColumn varchar(38) declare @IsInsert bit = 0 declare @Xdate datetime = getutcdate() declare @XUser nvarchar(64) = object_name4(@@procid) declare @Msg nvarchar(1000) SET XACT_ABORT OFF BEGIN TRY select top 1 @UID_DialogColumn = c.UID_DialogColumn from DialogTable t with (readpast5) join DialogColumn c with (readpast) on t.UID_DialogTable = c.UID_DialogTable where c.ColumnName = @ColumnName and t.TableName = @TableName if @UID_DialogColumn6 is null begin select @Msg = '#LDS#Column {0} not found in table {1}.|' + @ColumnName + '|' + @TableName + '|' raiserror(@msg, 18, 1 ) with nowait end 7if @UID_QERRiskIndex is null begin select top 1 @UID_QERRiskIndex from QERRiskIndex r where r.UID_DialogColumn = @UID_DialogColumn and r.DisplayValue =8 @DisplayValue and r.TypeOfCalculation = @TypeOfCalculation end if @UID_QERRiskIndex is null begin select @UID_QERRiskIndex = dbo.QBM_FCVGuidToTransfer9(newid(), dbo.QBM_FGIDBOwner() ) end if not exists (select top 1 1 from QERRiskIndex r where r.UID_QERRiskIndex = @UID_QERRiskIndex ) begin select @IsInsert10 = 1 end if @IsInsert = 1 begin insert into QERRiskIndex(Description, DisplayValue, IsInActive, QueryString , TypeOfCalculation, UID_DialogColumn, UID_QERRiskIndex11, Weight , XDateInserted, XDateUpdated, XUserInserted, XUserUpdated , XObjectKey ) select @Description, @DisplayValue, @IsInActive, @QueryString , @TypeOfCalculation12, @UID_DialogColumn, @UID_QERRiskIndex, @Weight , @XDate, @Xdate, @XUser, @XUser , dbo.QBM_FCVElementToObjectKey1('QERRiskIndex', 'UID_QERRiskIndex', @UID_QERRiskIndex13) end else begin update QERRiskIndex set Description = @Description  , IsInActive = @IsInActive , QueryString = @QueryString  , Weight = @Weight , XDateUpdated14 = @Xdate , XUserUpdated = @XUser where UID_QERRiskIndex = @UID_QERRiskIndex end END TRY BEGIN CATCH exec QBM_PSessionErrorAdd default declare @Rethrow15 varchar(1000) = dbo.QBM_FGISessionErrorRethrow() RAISERROR (@Rethrow, 18, 1) WITH NOWAIT END CATCH ende: return end 16