Back to OIM Explorer

dbo.QBM_PViewBuildU_intern

Stored ProcedureSQL_STORED_PROCEDURESandbox DB

Stored Procedure.

Source: sandbox-db sys.sql_modules

Source size: 2.031 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_FGISessionErrorRethrow source text reference
  • references source dbo.QBM_FGITableName source text reference
  • references source dbo.QBM_PDialogColumnDelete source text reference
  • references source dbo.QBM_PDialogColumnInsert source text reference
  • references source dbo.QBM_PSessionErrorAdd source text reference
  • references source dbo.QBM_PViewBuild source text reference
  • references source dbo.QBM_PViewBuild_FromAddOn source text reference
  • references source dbo.QBM_PViewBuildU source text reference
  • references source dbo.QBM_PViewDrop source text reference

Complete Source

SQL99 lines
1CREATE PROCEDURE QBM_PViewBuildU_intern(2  @UID_DialogTableU varchar(38),3  @GenProcID varchar(38),4  @ModuleName varchar(3) = '',5  @AutoCorrectColumns BIT = 06)7AS8BEGIN9  DECLARE @SQLcmd nvarchar(max)10  DECLARE @TableNameU varchar(38)11  DECLARE @DebugSwitch int = 012  DECLARE @DebugLevel varchar(1) = 'W'13  DECLARE @XUser nvarchar(64) = object_name(@@procid)14  DECLARE @Xdate datetime = getutcdate()15  SET XACT_ABORT OFF16  BEGIN TRY17    SELECT @TableNameU = dbo.QBM_FGITableName(@UID_DialogTableU)18    IF EXISTS(19      SELECT TOP 1 120      FROM information_schema.tables21      WHERE22        table_name = @TableNameu AND table_type = 'VIEW') AND NOT EXISTS(23    SELECT TOP 1 124    FROM DialogTable t25    WHERE26      t.TableName = @TableNameU)27    BEGIN28      EXEC QBM_PViewDrop @TableNameU29    END30    IF NOT EXISTS(31      SELECT TOP 1 132      FROM DialogTable t33      WHERE34        t.TableName = @TableNameU AND t.TableType = 'U')35    BEGIN36      GOTO endLabel37    END38    IF NOT EXISTS(39      SELECT TOP 1 140      FROM DialogTable t41      WHERE42        t.UID_DialogTable = @UID_DialogTableU)43    BEGIN44      GOTO endLabel45    END46    IF @DebugSwitch > 047    BEGIN48      SELECT *49      FROM QBMViewAddOn50      WHERE51        UID_DialogTable = @UID_DialogTableU52    END53    EXEC QBM_PViewBuild_FromAddOn @UID_DialogTableU54    IF @AutoCorrectColumns = 155    BEGIN56      EXEC QBM_PDialogColumnDelete @TableNameU,57        @GenProcID58      EXEC QBM_PDialogColumnInsert @TableNameU,59        @GenProcID,60        @ModuleName61      IF NOT EXISTS(62        SELECT TOP 1 163        FROM DialogTable t64        WITH(readpast)65      JOIN DialogColumn c66        WITH(readpast)67        ON t.UID_DialogTable = c.UID_DialogTable68      WHERE69        t.TableName = @TableNameU AND c.IsPKMember = 1)70      BEGIN71        IF @DebugSwitch = 172        BEGIN73          print 'bisher kein PK gefunden'74        END75        UPDATE DialogColumn76        SET IsPKMember = 1,77        XDateUpdated = @Xdate,78        XUserUpdated = @XUser79        FROM DialogTable t80          WITH(readpast)81        JOIN DialogColumn c82          WITH(readpast)83          ON t.UID_DialogTable = c.UID_DialogTable84        WHERE85          t.TableName = @TableNameU AND c.ColumnName = 'XObjectKey'86      END87    END88  END TRY89  BEGIN CATCH90    EXEC QBM_PSessionErrorAdd DEFAULT91    DECLARE @Rethrow varchar(1000) = dbo.QBM_FGISessionErrorRethrow()92    RAISERROR(@Rethrow,93    18,94    1)95      WITH NOWAIT96  END CATCH97  endLabel:98  RETURN99END
Open raw exported source
SQL ยท Raw14 lines
1      create   procedure QBM_PViewBuildU_intern ( @UID_DialogTableU varchar(38) , @GenProcID varchar(38) , @ModuleName varchar(3) = '' , @AutoCorrectColumns2 bit = 0 ) as begin  declare @SQLcmd nvarchar(max) declare @TableNameU varchar(38) declare @DebugSwitch int = 0 declare @DebugLevel varchar(1) = 'W' declare3 @XUser nvarchar(64) = object_name(@@procid) declare @Xdate datetime = getutcdate() SET XACT_ABORT OFF BEGIN TRY select @TableNameU = dbo.QBM_FGITableName4(@UID_DialogTableU) if exists (select top 1 1 from information_schema.tables where table_name = @TableNameu and table_type = 'VIEW' ) and not exists (select5 top 1 1 from DialogTable t where t.TableName = @TableNameU ) begin exec QBM_PViewDrop @TableNameU end if not exists (select top 1 1 from DialogTable t6 where t.TableName = @TableNameU and t.TableType = 'U' ) begin goto endLabel end  if not exists (select top 1 1 from DialogTable t where t.UID_DialogTable7 = @UID_DialogTableU ) begin goto endLabel end if @DebugSwitch > 0 begin select * from QBMViewAddOn where UID_DialogTable = @UID_DialogTableU end  exec8 QBM_PViewBuild_FromAddOn @UID_DialogTableU if @AutoCorrectColumns = 1 begin exec QBM_PDialogColumnDelete @TableNameU , @GenProcID exec QBM_PDialogColumnInsert9 @TableNameU , @GenProcID, @ModuleName  if not exists (select top 1 1 from DialogTable t with (readpast) join DialogColumn c with (readpast) on t.UID_DialogTable10 = c.UID_DialogTable where t.TableName = @TableNameU and c.IsPKMember = 1 ) begin if @DebugSwitch = 1 begin print 'bisher kein PK gefunden' end  Update11 DialogColumn set IsPKMember = 1 , XDateUpdated = @Xdate , XUserUpdated = @XUser from DialogTable t with (readpast) join DialogColumn c with (readpast)12 on t.UID_DialogTable = c.UID_DialogTable where t.TableName = @TableNameU and c.ColumnName = 'XObjectKey' end end END TRY BEGIN CATCH exec QBM_PSessionErrorAdd13 default declare @Rethrow varchar(1000) = dbo.QBM_FGISessionErrorRethrow() RAISERROR (@Rethrow, 18, 1) WITH NOWAIT END CATCH endLabel: return end 14