Back to OIM Explorer

dbo.QBM_PTableMove

Stored ProcedureSQL_STORED_PROCEDURESandbox DB

Stored Procedure.

Source: sandbox-db sys.sql_modules

Source size: 1.872 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_FGIDiskStoreExisting source text reference
  • references source dbo.QBM_FGIDiskStoreTarget source text reference
  • references source dbo.QBM_FGISingleUserRunning source text reference
  • references source dbo.QBM_PJournal source text reference
  • references source dbo.QBM_PSingleUserRelease source text reference
  • references source dbo.QBM_PSingleUserRequest source text reference
  • references source dbo.QBM_PTableReload source text reference
  • references source dbo.QBM_PWatchDogPrepare source text reference

Complete Source

SQL87 lines
1CREATE PROCEDURE QBM_PTableMove(2  @TablePattern varchar(64) = '%'3)4AS5BEGIN6  DECLARE @TableName varchar(30)7  DECLARE @Message nvarchar(1000)8  DECLARE @DebugSwitch int = 09  DECLARE @DebugLevel varchar(1) = 'W'10  IF dbo.QBM_FGISingleUserRunning() = 111  BEGIN12    SELECT @Message = 'single user mode is set by another user'13    RAISERROR(@message,14    18,15    1)16      WITH nowait17  END18  IF EXISTS(19    SELECT TOP 1 120    FROM sys.sysprocesses p21    WHERE22      p.dbid = DB_ID() AND p.spid <> @@SPID AND p.program_name LIKE CONCAT('OneIM_DatabaseAgent', '%'))23  BEGIN24    SELECT25      @Message = 'There are other processes active, use "exec QBM_PWatchDogPrepare 1" to deactivate them'26    RAISERROR(@message,27    18,28    1)29      WITH nowait30  END31  IF @@TRANCOUNT > 032  BEGIN33    SELECT @Message = 'procedure must not be used within transaction(s)'34    RAISERROR(@message,35    18,36    1)37      WITH nowait38  END39  EXEC QBM_PSingleUserRequest40  SELECT @TableName = '#'41  WHILE @TableName > ' '42  BEGIN43    SELECT @TableName = NULL44    SELECT TOP 1 @TableName = t.TableName45    FROM DialogTable t46    WHERE47      t.TableType IN('B',48    'T') AND dbo.QBM_FGIDiskStoreExisting(t.TableName) <> dbo.QBM_FGIDiskStoreTarget(t.TableName) AND t.TableName LIKE @TablePattern AND t.TableName49    NOT IN(50    SELECT TableName51    FROM QBM_VStartupTables52    UNION53    SELECT 'QBMDiskStoreLogical'54    UNION55    SELECT 'QBMDiskStorePhysical') AND EXISTS(56    SELECT TOP 1 157    FROM QBM_VTablesReloadAble v58    WHERE59      v.TableName = t.TableName)60    IF @TableName IS NULL61    BEGIN62      CONTINUE63    END64    SELECT65      @Message = 'Table to move ' + @TableName + ' from ' + dbo.QBM_FGIDiskStoreExisting(@TableName) + ' to ' + dbo.QBM_FGIDiskStoreTarget(@TableName66      )67    IF @DebugSwitch > 068    BEGIN69      print @message70    END71    SELECT72      @Message = REPLACE(@Message,73      ' to move ',74      ' moved ')75    EXEC QBM_PJournal @Message,76      @@procid,77    'I',78      @DebugLevel79    EXEC QBM_PTableReload @TableName,80    0,81      @Genprocid = NULL,82      @DiskStoreMove = 183  END84  endLabel:85  EXEC QBM_PSingleUserRelease86  RETURN87END
Open raw exported source
SQL · Raw13 lines
1  create   procedure QBM_PTableMove (@TablePattern varchar(64) = '%' ) as begin declare @TableName varchar(30) declare @Message nvarchar(1000) declare2 @DebugSwitch int = 0 declare @DebugLevel varchar(1) = 'W'   if dbo.QBM_FGISingleUserRunning() = 1  begin select @Message = 'single user mode is set by another user'3 raiserror (@message, 18, 1) with nowait end if exists (select top 1 1  from sys.sysprocesses p where p.dbid = DB_ID() and p.spid <> @@SPID and p.program_name4 like concat( 'OneIM_DatabaseAgent' ,'%'  ) ) begin select @Message = 'There are other processes active, use "exec QBM_PWatchDogPrepare 1" to deactivate them'5 raiserror (@message, 18, 1) with nowait end if @@TRANCOUNT > 0 begin select @Message = 'procedure must not be used within transaction(s)' raiserror (@message6, 18, 1) with nowait end  exec QBM_PSingleUserRequest select @TableName = '#' while @TableName > ' ' begin select @TableName = null select top 1 @TableName7 = t.TableName from DialogTable t where t.TableType in ('B', 'T') and dbo.QBM_FGIDiskStoreExisting(t.TableName) <> dbo.QBM_FGIDiskStoreTarget(t.TableName8) and t.TableName like @TablePattern  and t.TableName not in ( select TableName from QBM_VStartupTables union select 'QBMDiskStoreLogical' union select9 'QBMDiskStorePhysical' ) and exists ( Select top 1 1 from QBM_VTablesReloadAble v where v.TableName = t.TableName ) if @TableName is null begin continue10 end select @Message = 'Table to move ' + @TableName + ' from ' + dbo.QBM_FGIDiskStoreExisting(@TableName) + ' to ' + dbo.QBM_FGIDiskStoreTarget(@TableName11) if @DebugSwitch > 0 begin print @message end select @Message = REPLACE(@Message, ' to move ', ' moved ') exec QBM_PJournal @Message, @@procid, 'I', @DebugLevel12 exec QBM_PTableReload @TableName, 0, @Genprocid = null , @DiskStoreMove = 1 end  endLabel: exec QBM_PSingleUserRelease return end 13