Back to OIM Explorer

dbo.QBM_PDialogColumnInsert

Stored ProcedureSQL_STORED_PROCEDURESandbox DB

Stored Procedure.

Source: sandbox-db sys.sql_modules

Source size: 3.314 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_FGIDBOwner source text reference
  • references source dbo.QBM_FGISessionContext source text reference
  • references source dbo.QBM_FGISessionErrorRethrow source text reference
  • references source dbo.QBM_FGIUID_DialogColumn source text reference
  • references source dbo.QBM_PJournal source text reference
  • references source dbo.QBM_PSessionContextSet source text reference
  • references source dbo.QBM_PSessionErrorAdd source text reference

Complete Source

SQL153 lines
1CREATE PROCEDURE QBM_PDialogColumnInsert(2  @TableName nvarchar(64),3  @GenProcID varchar(38) = '',4  @ModuleName varchar(3) = ''5)6AS7BEGIN8  DECLARE @Columnname nvarchar(64)9  DECLARE @uid_dialogColumn varchar(38)10  DECLARE @msg nvarchar(1000)11  DECLARE @XUser nvarchar(64)12  DECLARE @XDate datetime13  DECLARE @SchemaDatatype nvarchar(256)14  DECLARE @SchemaDatalen int15  DECLARE @uid_dialogTable varchar(38)16  DECLARE @GenProcID_R varchar(38) = dbo.QBM_FGISessionContext('')17  DECLARE @XUser_R nvarchar(64) = dbo.QBM_FGISessionContext('XUser')18  DECLARE @DebugSwitch int = 019  DECLARE @DebugLevel char(1) = 'W'20  DECLARE @ElementBuffer QBM_YCursorBuffer21  DECLARE @ElementCount int22  DECLARE @ElementIndex int23  SET XACT_ABORT OFF24  BEGIN TRY25    IF isnull(@GenProcID,26    '') = ''27    BEGIN28      SELECT @GenProcID = @GenProcID_R29    END30    IF isnull(@ModuleName,31    '') = ''32    BEGIN33      SELECT @ModuleName = dbo.QBM_FGIDBOwner()34    END35    SELECT @XUser = @XUser_R36    SELECT @Xdate = getUTCDate()37    SELECT TOP 1 @uid_dialogTable = t.UID_DialogTable38    FROM DialogTable t39    WHERE40      t.TableName = @TableName41    IF @DebugSwitch > 042    BEGIN43      print '@uid_dialogTable' + @uid_dialogTable44      SELECT45        ic.Column_name,46        ic.DATA_TYPE,47        ic.CHARACTER_MAXIMUM_LENGTH48      FROM information_schema.columns ic49      LEFT50      OUTER51      JOIN(52      SELECT53        c.ColumnName,54        t.TableName55      FROM dialogcolumn c56      JOIN DialogTable t57        ON c.UID_DialogTable = t.UID_DialogTable) AS x58        ON x.TableName = ic.TABLE_NAME AND x.ColumnName = ic.COLUMN_NAME59      WHERE60        x.TableName IS NULL AND ic.table_name = @TableName61    END62    INSERT INTO @ElementBuffer(Ident1,63    Ident2,64    Int1)65    SELECT66      ic.Column_name,67      ic.DATA_TYPE,68      ic.CHARACTER_MAXIMUM_LENGTH69    FROM information_schema.columns ic70    LEFT71    OUTER72    JOIN(73    SELECT74      c.ColumnName,75      t.TableName76    FROM dialogcolumn c77    JOIN DialogTable t78      ON c.UID_DialogTable = t.UID_DialogTable) AS x79      ON x.TableName = ic.TABLE_NAME AND x.ColumnName = ic.COLUMN_NAME80    WHERE81      x.TableName IS NULL AND ic.table_name = @TableName82    SELECT @ElementCount = @@ROWCOUNT83    SELECT @ElementIndex = 184    WHILE @ElementIndex <= @ElementCount85    BEGIN86      SELECT87        TOP 1 @Columnname = bu.Ident1,88        @SchemaDatatype = bu.Ident2,89        @SchemaDatalen = bu.Int190      FROM @ElementBuffer bu91      WHERE92        bu.ElementIndex = @ElementIndex93      SELECT @msg = N 'Column in DialogColumn inserted : ' + @TableName + N '.' + @Columnname94      IF @DebugSwitch > 095      BEGIN96        print isnull(@msg,97        'Column in DialogColumn inserted')98      END99      EXEC QBM_PJournal @msg,100        @@PROCID,101      'I',102        @DebugLevel103      SELECT104        @uid_dialogColumn = dbo.QBM_FGIUID_DialogColumn(@TableName,105        @Columnname,106        @ModuleName)107      EXEC QBM_PSessionContextSet 'GenProcID',108        @GenProcID109      EXEC QBM_PSessionContextSet 'XUser',110        @XUser111      INSERT INTO dialogcolumn(UID_DialogColumn,112      uid_dialogtable,113      columnname,114      XObjectKey,115      xdateinserted,116      xdateupdated,117      xuserinserted,118      xuserupdated,119      SchemaDataType,120      SchemaDatalen,121      Caption)122      SELECT123        @uid_dialogColumn,124        @uid_dialogTable,125        @Columnname,126        dbo.QBM_FCVElementToObjectKey1('DialogColumn',127        'UID_DialogColumn',128        @uid_dialogColumn),129        @Xdate,130        @Xdate,131        @XUser,132        @XUser,133        @SchemaDatatype,134        @SchemaDatalen,135        @Columnname136      SELECT @ElementIndex += 1137    END138  END TRY139  BEGIN CATCH140    EXEC QBM_PSessionErrorAdd DEFAULT141    DECLARE @Rethrow varchar(1000) = dbo.QBM_FGISessionErrorRethrow()142    RAISERROR(@Rethrow,143    18,144    1)145      WITH NOWAIT146  END CATCH147  ende:148  EXEC QBM_PSessionContextSet 'GenProcID',149    @GenProcID_R150  EXEC QBM_PSessionContextSet 'XUser',151    @XUser_R152  RETURN153END
Open raw exported source
SQL ยท Raw22 lines
1    create   procedure QBM_PDialogColumnInsert( @TableName nvarchar(64), @GenProcID varchar(38) = '' , @ModuleName varchar(3) = '' ) as begin   2 declare @Columnname nvarchar(64) declare @uid_dialogColumn varchar(38) declare @msg nvarchar(1000) declare @XUser nvarchar(64) declare @XDate datetime3 declare @SchemaDatatype nvarchar(256) declare @SchemaDatalen int declare @uid_dialogTable varchar(38) declare @GenProcID_R varchar(38) = dbo.QBM_FGISessionContext4('') declare @XUser_R nvarchar(64) = dbo.QBM_FGISessionContext('XUser')  declare @DebugSwitch int = 0 declare @DebugLevel char(1) = 'W' declare @ElementBuffer5 QBM_YCursorBuffer declare @ElementCount int declare @ElementIndex int SET XACT_ABORT OFF BEGIN TRY if isnull(@GenProcID, '') = '' begin select @GenProcID6 = @GenProcID_R end if isnull(@ModuleName, '') = '' begin select @ModuleName = dbo.QBM_FGIDBOwner() end select @XUser = @XUser_R select @Xdate = getUTCDate7() select top 1 @uid_dialogTable = t.UID_DialogTable from DialogTable t where t.TableName = @TableName if @DebugSwitch > 0 begin print '@uid_dialogTable'8 + @uid_dialogTable select ic.Column_name, ic.DATA_TYPE, ic.CHARACTER_MAXIMUM_LENGTH from information_schema.columns ic left outer join ( select c.ColumnName9, t.TableName from dialogcolumn c join DialogTable t on c.UID_DialogTable = t.UID_DialogTable ) as x on x.TableName = ic.TABLE_NAME and x.ColumnName = 10ic.COLUMN_NAME where x.TableName is null and ic.table_name = @TableName end insert into @ElementBuffer (Ident1, Ident2, Int1) select ic.Column_name, ic.DATA_TYPE11, ic.CHARACTER_MAXIMUM_LENGTH from information_schema.columns ic left outer join ( select c.ColumnName, t.TableName from dialogcolumn c join DialogTable12 t on c.UID_DialogTable = t.UID_DialogTable ) as x on x.TableName = ic.TABLE_NAME and x.ColumnName = ic.COLUMN_NAME where x.TableName is null and ic.table_name13 = @TableName select @ElementCount = @@ROWCOUNT select @ElementIndex = 1 while @ElementIndex <= @ElementCount begin select top 1 @Columnname = bu.Ident114 , @SchemaDatatype = bu.Ident2 , @SchemaDatalen = bu.Int1 from @ElementBuffer bu where bu.ElementIndex = @ElementIndex select @msg = N'Column in DialogColumn inserted : '15 + @TableName + N'.' + @Columnname if @DebugSwitch > 0 begin print isnull(@msg, 'Column in DialogColumn inserted' ) end exec QBM_PJournal @msg, @@PROCID16, 'I', @DebugLevel   select @uid_dialogColumn = dbo.QBM_FGIUID_DialogColumn (@TableName, @Columnname, @ModuleName) exec QBM_PSessionContextSet 'GenProcID'17, @GenProcID exec QBM_PSessionContextSet 'XUser', @XUser insert into dialogcolumn (UID_DialogColumn, uid_dialogtable, columnname, XObjectKey , xdateinserted18, xdateupdated, xuserinserted, xuserupdated , SchemaDataType, SchemaDatalen , Caption ) select @uid_dialogColumn, @uid_dialogTable, @Columnname, dbo.QBM_FCVElementToObjectKey119('DialogColumn', 'UID_DialogColumn', @uid_dialogColumn) , @Xdate, @Xdate, @XUser, @XUser ,@SchemaDatatype, @SchemaDatalen , @Columnname select @ElementIndex20 += 1 end  END TRY BEGIN CATCH exec QBM_PSessionErrorAdd default declare @Rethrow varchar(1000) = dbo.QBM_FGISessionErrorRethrow() RAISERROR (@Rethrow,21 18, 1) WITH NOWAIT END CATCH  ende: exec QBM_PSessionContextSet 'GenProcID', @GenProcID_R exec QBM_PSessionContextSet 'XUser', @XUser_R return end 22