dbo.QBM_PQBMRelationExpand_One
Stored ProcedureSQL_STORED_PROCEDURESandbox DB
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_FCVAnyToHash source text reference
- references source dbo.QBM_FCVBinaryToString source text reference
- references source dbo.QBM_FCVElementToObjectKey1 source text reference
- references source dbo.QBM_FCVGUIDToModuleOwner source text reference
- references source dbo.QBM_FGIDBOwner source text reference
- references source dbo.QBM_FGIModuleHigher source text reference
- references source dbo.QBM_FGISessionErrorRethrow source text reference
- references source dbo.QBM_PQBMRelationExpand source text reference
- references source dbo.QBM_PSessionErrorAdd source text reference
Complete Source
1CREATE PROCEDURE QBM_PQBMRelationExpand_One(2 @UID_QBMRelation varchar(38)3)4AS5BEGIN6 DECLARE @ModuleOwner varchar(3)7 DECLARE @UID_QBMRelationBase varchar(38)8 DECLARE @UID_DialogTableParent varchar(38)9 DECLARE @UID_ParentColumn varchar(38)10 DECLARE @UID_DialogTableChild varchar(38)11 DECLARE @UID_ChildColumn varchar(38)12 DECLARE @Xdate datetime = getutcdate()13 DECLARE @XUser nvarchar(64) = object_name(@@procid)14 DECLARE @tabletypeParent varchar(1)15 DECLARE @tabletypeChild varchar(1)16 DECLARE @parentcolumn varchar(30)17 DECLARE @Childcolumn varchar(30)18 DECLARE @DebugSwitch int = 019 DECLARE @CountItems int20 DECLARE @RelationIDab4 nvarchar(64)21 DECLARE @UID_QBMRelationAb4 varchar(38)22 DECLARE @RelationID nvarchar(64)23 DECLARE @ParentRestriction nchar(2),24 @ParentExecuteBy nchar(1),25 @ParentAllowUpdate BIT,26 @ChildRestriction nchar(2),27 @ChildExecuteBy nchar(1),28 @ChildAllowUpdate BIT29 DECLARE @QBMRelation TABLE(RelationID nvarchar(64) collate database_default,30 UID_QBMRelation varchar(38) collate database_default,31 UID_ParentColumn varchar(38) collate database_default,32 ParentRestriction varchar(2) collate database_default,33 ParentExecuteBy varchar(1) collate database_default,34 ParentAllowUpdate BIT,35 UID_ChildColumn varchar(38) collate database_default,36 ChildRestriction varchar(2) collate database_default,37 ChildExecuteBy varchar(1) collate database_default,38 ChildAllowUpdate BIT,39 UID_QBMRelationBase varchar(38) collate database_default)40 SET XACT_ABORT OFF41 BEGIN TRY42 SELECT @ModuleOwner = dbo.QBM_FGIDBOwner()43 IF @UID_QBMRelation LIKE '%-Base'44 BEGIN45 IF @DebugSwitch > 046 BEGIN47 print '@UID_QBMRelation ' + @UID_QBMRelation + ' einkürzen'48 END49 SELECT50 TOP 1 @UID_QBMRelation = substring(@UID_QBMRelation,51 1,52 LEN(@UID_QBMRelation) - len('-Base')),53 @UID_QBMRelationBase = v.UID_QBMRelationBase,54 @UID_DialogTableParent = v.UID_DialogTableParent,55 @tabletypeParent = tp.TableType,56 @UID_ParentColumn = v.UID_ParentColumn,57 @parentcolumn = v.ParentColumn,58 @UID_DialogTableChild = vb.UID_DialogTableChild,59 @tabletypeChild = tcb.TableType,60 @UID_ChildColumn = vb.UID_ChildColumn,61 @Childcolumn = vb.ChildColumn,62 @RelationID = v.RelationID,63 @RelationIDab4 = substring(substring(vb.relationid, 4, 60),64 1,65 LEN(substring(vb.relationid, 4, 60)) - len('-Base')),66 @UID_QBMRelationAb4 = substring(substring(vb.UID_QBMRelation, 4, 34),67 1,68 LEN(substring(vb.UID_QBMRelation, 4, 34)) - len('-Base')),69 @ParentRestriction = v.ParentRestriction,70 @ParentExecuteBy = v.ParentExecuteBy,71 @ParentAllowUpdate = v.ParentAllowUpdate,72 @ChildRestriction = vb.ChildRestriction,73 @ChildExecuteBy = vb.ChildExecuteBy,74 @ChildAllowUpdate = vb.ChildAllowUpdate75 FROM QBM_VQBMRelation v76 JOIN DialogTable tp77 ON v.UID_DialogTableParent = tp.UID_DialogTable78 JOIN DialogTable tc79 ON v.UID_DialogTableChild = tc.UID_DialogTable80 JOIN QBM_VQBMRelation vb81 ON vb.UID_QBMRelation = @UID_QBMRelation82 JOIN DialogTable tpb83 ON vb.UID_DialogTableParent = tpb.UID_DialogTable84 JOIN DialogTable tcb85 ON vb.UID_DialogTableChild = tcb.UID_DialogTable86 WHERE87 v.UID_QBMRelationBase = @UID_QBMRelation88 END89 ELSE90 BEGIN91 SELECT92 TOP 1 @UID_QBMRelationBase = v.UID_QBMRelationBase,93 @UID_DialogTableParent = v.UID_DialogTableParent,94 @tabletypeParent = tp.TableType,95 @UID_ParentColumn = v.UID_ParentColumn,96 @parentcolumn = v.ParentColumn,97 @UID_DialogTableChild = v.UID_DialogTableChild,98 @tabletypeChild = tc.TableType,99 @UID_ChildColumn = v.UID_ChildColumn,100 @Childcolumn = v.ChildColumn,101 @RelationID = v.RelationID,102 @RelationIDab4 = substring(v.relationid,103 4,104 60),105 @UID_QBMRelationAb4 = substring(v.UID_QBMRelation,106 4,107 34),108 @ParentRestriction = v.ParentRestriction,109 @ParentExecuteBy = v.ParentExecuteBy,110 @ParentAllowUpdate = v.ParentAllowUpdate,111 @ChildRestriction = v.ChildRestriction,112 @ChildExecuteBy = v.ChildExecuteBy,113 @ChildAllowUpdate = v.ChildAllowUpdate114 FROM QBM_VQBMRelation v115 JOIN DialogTable tp116 ON v.UID_DialogTableParent = tp.UID_DialogTable117 JOIN DialogTable tc118 ON v.UID_DialogTableChild = tc.UID_DialogTable119 WHERE120 v.UID_QBMRelation = @UID_QBMRelation121 IF @UID_QBMRelationBase > ' '122 BEGIN123 IF @DebugSwitch > 0124 BEGIN125 print 'nicht leere Basis Relation'126 END127 GOTO endlabel128 END129 END130 IF @DebugSwitch > 0131 BEGIN132 print '@RelationID ' + @RelationID print '@RelationIDab4 ' + @RelationIDab4 print '@UID_QBMRelationAb4 ' + @UID_QBMRelationAb4 print '@UID_QBMRelationBase '133 + isnull(@UID_QBMRelationBase,134 '<null>') print @UID_DialogTableParent + ' ' + @tabletypeParent + ' ' +@parentcolumn + ' ' + @uid_parentColumn print @UID_DialogTableChild + ' '135 + @tabletypeChild + ' ' +@Childcolumn + ' ' + @uid_ChildColumn136 END137 IF @DebugSwitch > 0138 BEGIN139 print 'wir machen was'140 END141 IF @UID_DialogTableChild IN('QER-T-BaseTreeCollection',142 'QER-T-BaseTreeExcludesBaseTree')143 BEGIN144 GOTO endLabel145 END146 IF @tabletypeParent IN('B',147 'T') AND @tabletypeChild = 'T'148 BEGIN149 IF @DebugSwitch > 0150 BEGIN151 print 'Es bleibt wie es ist'152 END153 GOTO endlabel154 END155 IF @tabletypeParent = 'B' AND @tabletypeChild = 'B'156 BEGIN157 IF @DebugSwitch > 0158 BEGIN159 print 'View auf beiden Seiten finden' print ' gefundenes wird relation, angegebenes wird basis'160 END161 INSERT INTO @QBMRelation(RelationID,162 UID_QBMRelation,163 UID_ParentColumn,164 ParentRestriction,165 ParentExecuteBy,166 ParentAllowUpdate,167 UID_ChildColumn,168 ChildRestriction,169 ChildExecuteBy,170 ChildAllowUpdate,171 UID_QBMRelationBase)172 SELECT173 @ModuleOwner + @RelationIDab4 + '-' + tvr.TableName,174 LEFT(@ModuleOwner + @UID_QBMRelationab4 + '-' + substring(dbo.QBM_FCVBinaryToString(dbo.QBM_FCVAnyToHash(upper(tvl.TableName)),175 0), 3, 40),176 36),177 cvl.UID_DialogColumn,178 @ParentRestriction,179 @ParentExecuteBy,180 @ParentAllowUpdate,181 cvr.UID_DialogColumn,182 @ChildRestriction,183 @ChildExecuteBy,184 @ChildAllowUpdate,185 @UID_QBMRelation186 FROM DialogTable tbr187 JOIN DialogTable tvr188 ON tbr.UID_DialogTable = @UID_DialogTableChild AND tvr.UID_DialogTableBase = tbr.UID_DialogTable189 JOIN DialogColumn cvr190 ON cvr.UID_DialogTable = tvr.UID_DialogTable AND cvr.UID_BaseColumn = @UID_ChildColumn191 JOIN DialogTable tbl192 ON tbl.UID_DialogTable = @UID_DialogTableParent193 JOIN DialogTable tvl194 ON tvl.UID_DialogTableBase = tbl.UID_DialogTable195 JOIN DialogColumn cvl196 ON cvl.UID_DialogTable = tvl.UID_DialogTable AND cvl.UID_BaseColumn = @UID_ParentColumn AND((cvl.ColumnName = cvr.ColumnName AND tvl.UID_DialogTable197 <> tvr.UID_DialogTable) OR(tbr.UID_DialogTable = tbl.UID_DialogTable AND tvr.UID_DialogTable = tvl.UID_DialogTable AND dbo.QBM_FCVGUIDToModuleOwner198 (@UID_ChildColumn) <> 'CCC'))199 GOTO BasisDefiniert200 END201 IF @tabletypeParent = 'T' AND @tabletypeChild = 'B'202 BEGIN203 IF @DebugSwitch > 0204 BEGIN205 print 'View auf Child-Seite finden' print ' gefundenes wird relation, angegebenes wird basis'206 END207 INSERT INTO @QBMRelation(RelationID,208 UID_QBMRelation,209 UID_ParentColumn,210 ParentRestriction,211 ParentExecuteBy,212 ParentAllowUpdate,213 UID_ChildColumn,214 ChildRestriction,215 ChildExecuteBy,216 ChildAllowUpdate,217 UID_QBMRelationBase)218 SELECT219 @ModuleOwner + @RelationIDab4 + '-' + tvr.TableName,220 LEFT(@ModuleOwner + @UID_QBMRelationab4 + '-' + substring(dbo.QBM_FCVBinaryToString(dbo.QBM_FCVAnyToHash(upper(tvr.TableName)),221 0), 3, 40),222 36),223 cTl.uid_dialogcolumn,224 @ParentRestriction,225 @ParentExecuteBy,226 @ParentAllowUpdate,227 cvr.UID_DialogColumn,228 @ChildRestriction,229 @ChildExecuteBy,230 @ChildAllowUpdate,231 dbo.QBM_FGIModulehigher(dbo.QBM_FCVGUIDToModuleOwner(cbr.UID_DialogColumn),232 dbo.QBM_FCVGUIDToModuleOwner(ctl.UID_DialogColumn)) + @UID_QBMRelationab4233 FROM DialogTable tbr234 JOIN DialogTable tvr235 ON tbr.UID_DialogTable = @UID_DialogTableChild AND tvr.UID_DialogTableBase = tbr.UID_DialogTable236 JOIN DialogColumn cvr237 ON cvr.UID_DialogTable = tvr.UID_DialogTable238 JOIN DialogColumn cbr239 ON cbr.UID_DialogTable = tbr.UID_DialogTable AND cvr.UID_BaseColumn = cbr.UID_DialogColumn AND cbr.UID_DialogColumn = @UID_ChildColumn240 JOIN DialogTable tTl241 ON tTl.UID_DialogTable = @UID_DialogTableParent242 JOIN DialogColumn cTl243 ON cTl.UID_DialogColumn = @UID_ParentColumn244 GOTO BasisDefiniert245 END246 IF @tabletypeParent = 'V' AND @tabletypeChild = 'B'247 BEGIN248 IF @DebugSwitch > 0249 BEGIN250 print 'Dann alle Parents beim Child finden und multiplizieren'251 END252 INSERT INTO @QBMRelation(RelationID,253 UID_QBMRelation,254 UID_ParentColumn,255 ParentRestriction,256 ParentExecuteBy,257 ParentAllowUpdate,258 UID_ChildColumn,259 ChildRestriction,260 ChildExecuteBy,261 ChildAllowUpdate,262 UID_QBMRelationBase)263 SELECT264 @ModuleOwner + @RelationIDab4 + '-' + tvr.TableName,265 LEFT(@ModuleOwner + @UID_QBMRelationab4 + '-' + substring(dbo.QBM_FCVBinaryToString(dbo.QBM_FCVAnyToHash(upper(tvr.TableName)),266 0), 3, 40),267 36),268 cvl.UID_DialogColumn,269 @ParentRestriction,270 @ParentExecuteBy,271 @ParentAllowUpdate,272 cvr.UID_DialogColumn,273 @ChildRestriction,274 @ChildExecuteBy,275 @ChildAllowUpdate,276 @UID_QBMRelation + '-Base'277 FROM DialogTable tvl278 JOIN DialogColumn cvl279 ON tvl.UID_DialogTable = @UID_DialogTableParent AND tvl.UID_DialogTable = cvl.UID_DialogTable AND cvl.UID_DialogColumn = @UID_ParentColumn280 JOIN DialogTable tbr281 ON tbr.UID_DialogTable = @UID_DialogTableChild282 JOIN DialogTable tvr283 ON tvr.UID_DialogTableBase = tbr.UID_DialogTable284 JOIN DialogColumn cbr285 ON cbr.UID_DialogColumn = @UID_ChildColumn AND cbr.UID_DialogTable = tbr.UID_DialogTable286 JOIN DialogColumn cvr287 ON cvr.UID_BaseColumn = cbr.UID_DialogColumn AND cvr.UID_DialogTable = tvr.UID_DialogTable288 GOTO BasisDefiniert289 END290 IF @tabletypeParent = 'V' AND @tabletypeChild = 'T'291 BEGIN292 IF @DebugSwitch > 0293 BEGIN294 print 'nichts zu erweitern, kann nur passieren wenn auch die View neu definiert wurde'295 END296 GOTO endlabel297 END298 IF @tabletypeParent = 'T' AND @tabletypeChild = 'V'299 BEGIN300 IF @DebugSwitch > 0301 BEGIN302 print 'kann beim erweitern nicht neu dazu kommen'303 END304 GOTO endlabel305 END306 IF @tabletypeParent = 'V' AND @tabletypeChild = 'V'307 BEGIN308 IF @DebugSwitch > 0309 BEGIN310 print 'kann beim erweitern nicht neu dazu kommen'311 END312 GOTO endlabel313 END314 BasisDefiniert:315 IF @DebugSwitch > 0316 BEGIN317 print 'nach datenermittlung'318 SELECT *319 FROM @QBMRelation320 END321 DELETE @QBMRelation322 FROM QBMRelation r323 JOIN @QBMRelation rn324 ON r.UID_ChildColumn = rn.UID_ChildColumn AND r.UID_ParentColumn = rn.UID_ParentColumn325 WHERE326 r.UID_QBMRelation <> rn.UID_QBMRelation327 IF @DebugSwitch > 0328 BEGIN329 print 'nach Ausputzen vorhandener Beziehungen'330 SELECT *331 FROM @QBMRelation332 END333 INSERT INTO QBMRelation(RelationID,334 UID_QBMRelation,335 UID_ParentColumn,336 ParentRestriction,337 ParentExecuteBy,338 ParentAllowUpdate,339 UID_ChildColumn,340 ChildRestriction,341 ChildExecuteBy,342 ChildAllowUpdate,343 XDateInserted,344 XDateUpdated,345 XUserInserted,346 XUserUpdated,347 XObjectKey,348 UID_QBMRelationBase,349 XTouched)350 SELECT351 rn.RelationID,352 rn.UID_QBMRelation,353 rn.UID_ParentColumn,354 rn.ParentRestriction,355 rn.ParentExecuteBy,356 rn.ParentAllowUpdate,357 rn.UID_ChildColumn,358 rn.ChildRestriction,359 rn.ChildExecuteBy,360 rn.ChildAllowUpdate,361 @Xdate,362 @Xdate,363 @XUser,364 @XUser,365 dbo.QBM_FCVElementToObjectKey1('QBMRelation',366 'UID_QBMRelation',367 rn.UID_QBMRelation),368 rn.UID_QBMRelationBase,369 'I'370 FROM @QBMRelation rn371 WHERE372 NOT EXISTS(373 SELECT TOP 1 1374 FROM QBMRelation re375 WHERE376 re.UID_QBMRelation = rn.UID_QBMRelation)377 SELECT @CountItems = @@ROWCOUNT378 IF @DebugSwitch > 0379 BEGIN380 print 'Zeilen eingefügt ' + str(@CountItems)381 END382 END TRY383 BEGIN CATCH384 EXEC QBM_PSessionErrorAdd DEFAULT385 DECLARE @Rethrow varchar(1000) = dbo.QBM_FGISessionErrorRethrow()386 RAISERROR(@Rethrow,387 18,388 1)389 WITH NOWAIT390 END CATCH391 endLabel:392END
Open raw exported source
1 create procedure QBM_PQBMRelationExpand_One ( @UID_QBMRelation varchar(38) ) as begin declare @ModuleOwner varchar(3) declare @UID_QBMRelationBase2 varchar(38) declare @UID_DialogTableParent varchar(38) declare @UID_ParentColumn varchar(38) declare @UID_DialogTableChild varchar(38) declare @UID_ChildColumn3 varchar(38) declare @Xdate datetime = getutcdate() declare @XUser nvarchar(64) = object_name(@@procid) declare @tabletypeParent varchar(1) declare @tabletypeChild4 varchar(1) declare @parentcolumn varchar(30) declare @Childcolumn varchar(30) declare @DebugSwitch int = 0 declare @CountItems int declare @RelationIDab45 nvarchar(64) declare @UID_QBMRelationAb4 varchar(38) declare @RelationID nvarchar(64) declare @ParentRestriction nchar(2) , @ParentExecuteBy nchar(1) 6, @ParentAllowUpdate bit , @ChildRestriction nchar(2) , @ChildExecuteBy nchar(1) , @ChildAllowUpdate bit declare @QBMRelation table ( RelationID nvarchar7(64) collate database_default , UID_QBMRelation varchar(38) collate database_default , UID_ParentColumn varchar(38) collate database_default , ParentRestriction8 varchar(2) collate database_default , ParentExecuteBy varchar(1) collate database_default , ParentAllowUpdate bit , UID_ChildColumn varchar(38) collate9 database_default , ChildRestriction varchar(2) collate database_default , ChildExecuteBy varchar(1) collate database_default , ChildAllowUpdate bit , 10UID_QBMRelationBase varchar(38) collate database_default ) SET XACT_ABORT OFF BEGIN TRY select @ModuleOwner = dbo.QBM_FGIDBOwner() if @UID_QBMRelation 11like '%-Base' begin if @DebugSwitch > 0 begin print '@UID_QBMRelation ' + @UID_QBMRelation + ' einkürzen' end select top 1 @UID_QBMRelation = substring12(@UID_QBMRelation, 1, LEN(@UID_QBMRelation) - len('-Base')) , @UID_QBMRelationBase = v.UID_QBMRelationBase , @UID_DialogTableParent = v.UID_DialogTableParent13 , @tabletypeParent = tp.TableType , @UID_ParentColumn = v.UID_ParentColumn , @parentcolumn = v.ParentColumn , @UID_DialogTableChild = vb.UID_DialogTableChild14 , @tabletypeChild = tcb.TableType , @UID_ChildColumn = vb.UID_ChildColumn , @Childcolumn = vb.ChildColumn , @RelationID = v.RelationID , @RelationIDab415 = substring(substring(vb.relationid, 4,60), 1, LEN(substring(vb.relationid, 4,60)) - len('-Base') ) , @UID_QBMRelationAb4 = substring(substring(vb.UID_QBMRelation16, 4,34), 1, LEN(substring(vb.UID_QBMRelation, 4,34)) - len('-Base') ) , @ParentRestriction = v.ParentRestriction , @ParentExecuteBy = v.ParentExecuteBy17 , @ParentAllowUpdate = v.ParentAllowUpdate , @ChildRestriction = vb.ChildRestriction , @ChildExecuteBy = vb.ChildExecuteBy , @ChildAllowUpdate = vb.ChildAllowUpdate18 from QBM_VQBMRelation v join DialogTable tp on v.UID_DialogTableParent = tp.UID_DialogTable join DialogTable tc on v.UID_DialogTableChild = tc.UID_DialogTable19 join QBM_VQBMRelation vb on vb.UID_QBMRelation = @UID_QBMRelation join DialogTable tpb on vb.UID_DialogTableParent = tpb.UID_DialogTable join DialogTable20 tcb on vb.UID_DialogTableChild = tcb.UID_DialogTable where v.UID_QBMRelationBase = @UID_QBMRelation end else begin select top 1 @UID_QBMRelationBase =21 v.UID_QBMRelationBase , @UID_DialogTableParent = v.UID_DialogTableParent , @tabletypeParent = tp.TableType , @UID_ParentColumn = v.UID_ParentColumn , 22@parentcolumn = v.ParentColumn , @UID_DialogTableChild = v.UID_DialogTableChild , @tabletypeChild = tc.TableType , @UID_ChildColumn = v.UID_ChildColumn23 , @Childcolumn = v.ChildColumn , @RelationID = v.RelationID , @RelationIDab4 = substring(v.relationid, 4,60) , @UID_QBMRelationAb4 = substring(v.UID_QBMRelation24, 4,34) , @ParentRestriction = v.ParentRestriction , @ParentExecuteBy = v.ParentExecuteBy , @ParentAllowUpdate = v.ParentAllowUpdate , @ChildRestriction25 = v.ChildRestriction , @ChildExecuteBy = v.ChildExecuteBy , @ChildAllowUpdate = v.ChildAllowUpdate from QBM_VQBMRelation v join DialogTable tp on v.UID_DialogTableParent26 = tp.UID_DialogTable join DialogTable tc on v.UID_DialogTableChild = tc.UID_DialogTable where v.UID_QBMRelation = @UID_QBMRelation if @UID_QBMRelationBase27 > ' ' begin if @DebugSwitch > 0 begin print 'nicht leere Basis Relation' end goto endlabel end end if @DebugSwitch > 0 begin print '@RelationID ' + @RelationID28 print '@RelationIDab4 ' + @RelationIDab4 print '@UID_QBMRelationAb4 ' + @UID_QBMRelationAb4 print '@UID_QBMRelationBase ' + isnull(@UID_QBMRelationBase29, '<null>') print @UID_DialogTableParent + ' ' + @tabletypeParent + ' ' +@parentcolumn + ' ' + @uid_parentColumn print @UID_DialogTableChild + ' ' + @tabletypeChild30 + ' ' +@Childcolumn + ' ' + @uid_ChildColumn end if @DebugSwitch > 0 begin print 'wir machen was' end if @UID_DialogTableChild in ('QER-T-BaseTreeCollection'31 , 'QER-T-BaseTreeExcludesBaseTree' ) begin goto endLabel end if @tabletypeParent in ('B', 'T') and @tabletypeChild = 'T' begin if @DebugSwitch > 0 begin32 print 'Es bleibt wie es ist' end goto endlabel end if @tabletypeParent = 'B' and @tabletypeChild = 'B' begin if @DebugSwitch > 0 begin print 'View auf beiden Seiten finden'33 print ' gefundenes wird relation, angegebenes wird basis' end insert into @QBMRelation (RelationID , UID_QBMRelation , UID_ParentColumn , ParentRestriction34, ParentExecuteBy, ParentAllowUpdate , UID_ChildColumn , ChildRestriction, ChildExecuteBy, ChildAllowUpdate , UID_QBMRelationBase ) select @ModuleOwner35 + @RelationIDab4 + '-' + tvr.TableName , left(@ModuleOwner + @UID_QBMRelationab4 + '-' + substring(dbo.QBM_FCVBinaryToString( dbo.QBM_FCVAnyToHash(upper36(tvl.TableName)), 0), 3,40), 36) , cvl.UID_DialogColumn , @ParentRestriction, @ParentExecuteBy, @ParentAllowUpdate , cvr.UID_DialogColumn , @ChildRestriction37, @ChildExecuteBy, @ChildAllowUpdate , @UID_QBMRelation from DialogTable tbr join DialogTable tvr on tbr.UID_DialogTable = @UID_DialogTableChild and tvr.UID_DialogTableBase38 = tbr.UID_DialogTable join DialogColumn cvr on cvr.UID_DialogTable = tvr.UID_DialogTable and cvr.UID_BaseColumn = @UID_ChildColumn join DialogTable tbl39 on tbl.UID_DialogTable = @UID_DialogTableParent join DialogTable tvl on tvl.UID_DialogTableBase = tbl.UID_DialogTable join DialogColumn cvl on cvl.UID_DialogTable40 = tvl.UID_DialogTable and cvl.UID_BaseColumn = @UID_ParentColumn and ( (cvl.ColumnName = cvr.ColumnName and tvl.UID_DialogTable <> tvr.UID_DialogTable41 ) or (tbr.UID_DialogTable = tbl.UID_DialogTable and tvr.UID_DialogTable = tvl.UID_DialogTable and dbo.QBM_FCVGUIDToModuleOwner(@UID_ChildColumn) <> 42'CCC' ) ) goto BasisDefiniert end if @tabletypeParent = 'T' and @tabletypeChild = 'B' begin if @DebugSwitch > 0 begin print 'View auf Child-Seite finden'43 print ' gefundenes wird relation, angegebenes wird basis' end insert into @QBMRelation (RelationID , UID_QBMRelation , UID_ParentColumn , ParentRestriction44, ParentExecuteBy, ParentAllowUpdate , UID_ChildColumn , ChildRestriction, ChildExecuteBy, ChildAllowUpdate , UID_QBMRelationBase ) select @ModuleOwner45 + @RelationIDab4 + '-' + tvr.TableName , left(@ModuleOwner + @UID_QBMRelationab4 + '-' + substring(dbo.QBM_FCVBinaryToString( dbo.QBM_FCVAnyToHash(upper46(tvr.TableName)), 0), 3,40) , 36) , cTl.uid_dialogcolumn , @ParentRestriction, @ParentExecuteBy, @ParentAllowUpdate , cvr.UID_DialogColumn , @ChildRestriction47, @ChildExecuteBy, @ChildAllowUpdate , dbo.QBM_FGIModulehigher(dbo.QBM_FCVGUIDToModuleOwner(cbr.UID_DialogColumn) , dbo.QBM_FCVGUIDToModuleOwner(ctl.UID_DialogColumn48 ) ) + @UID_QBMRelationab4 from DialogTable tbr join DialogTable tvr on tbr.UID_DialogTable = @UID_DialogTableChild and tvr.UID_DialogTableBase = tbr.UID_DialogTable49 join DialogColumn cvr on cvr.UID_DialogTable = tvr.UID_DialogTable join DialogColumn cbr on cbr.UID_DialogTable = tbr.UID_DialogTable and cvr.UID_BaseColumn50 = cbr.UID_DialogColumn and cbr.UID_DialogColumn = @UID_ChildColumn join DialogTable tTl on tTl.UID_DialogTable = @UID_DialogTableParent join DialogColumn51 cTl on cTl.UID_DialogColumn = @UID_ParentColumn goto BasisDefiniert end if @tabletypeParent = 'V' and @tabletypeChild = 'B' begin if @DebugSwitch >52 0 begin print 'Dann alle Parents beim Child finden und multiplizieren' end insert into @QBMRelation (RelationID , UID_QBMRelation , UID_ParentColumn 53, ParentRestriction, ParentExecuteBy, ParentAllowUpdate , UID_ChildColumn , ChildRestriction, ChildExecuteBy, ChildAllowUpdate , UID_QBMRelationBase ) 54 select @ModuleOwner + @RelationIDab4 + '-' + tvr.TableName , left(@ModuleOwner + @UID_QBMRelationab4 + '-' + substring(dbo.QBM_FCVBinaryToString( dbo.QBM_FCVAnyToHash55(upper(tvr.TableName)), 0), 3,40) , 36) , cvl.UID_DialogColumn , @ParentRestriction, @ParentExecuteBy, @ParentAllowUpdate , cvr.UID_DialogColumn , @ChildRestriction56, @ChildExecuteBy, @ChildAllowUpdate , @UID_QBMRelation + '-Base' from DialogTable tvl join DialogColumn cvl on tvl.UID_DialogTable = @UID_DialogTableParent57 and tvl.UID_DialogTable = cvl.UID_DialogTable and cvl.UID_DialogColumn = @UID_ParentColumn join DialogTable tbr on tbr.UID_DialogTable = @UID_DialogTableChild58 join DialogTable tvr on tvr.UID_DialogTableBase = tbr.UID_DialogTable join DialogColumn cbr on cbr.UID_DialogColumn = @UID_ChildColumn and cbr.UID_DialogTable59 = tbr.UID_DialogTable join DialogColumn cvr on cvr.UID_BaseColumn = cbr.UID_DialogColumn and cvr.UID_DialogTable = tvr.UID_DialogTable goto BasisDefiniert60 end if @tabletypeParent = 'V' and @tabletypeChild = 'T' begin if @DebugSwitch > 0 begin print 'nichts zu erweitern, kann nur passieren wenn auch die View neu definiert wurde'61 end goto endlabel end if @tabletypeParent = 'T' and @tabletypeChild = 'V' begin if @DebugSwitch > 0 begin print 'kann beim erweitern nicht neu dazu kommen'62 end goto endlabel end if @tabletypeParent = 'V' and @tabletypeChild = 'V' begin if @DebugSwitch > 0 begin print 'kann beim erweitern nicht neu dazu kommen'63 end goto endlabel end BasisDefiniert: if @DebugSwitch > 0 begin print 'nach datenermittlung' select * from @QBMRelation end delete @QBMRelation from64 QBMRelation r join @QBMRelation rn on r.UID_ChildColumn = rn.UID_ChildColumn and r.UID_ParentColumn = rn.UID_ParentColumn where r.UID_QBMRelation <> rn.UID_QBMRelation65 if @DebugSwitch > 0 begin print 'nach Ausputzen vorhandener Beziehungen' select * from @QBMRelation end insert into QBMRelation ( RelationID , UID_QBMRelation66 , UID_ParentColumn , ParentRestriction , ParentExecuteBy , ParentAllowUpdate , UID_ChildColumn , ChildRestriction , ChildExecuteBy , ChildAllowUpdate 67, XDateInserted, XDateUpdated, XUserInserted, XUserUpdated, XObjectKey , UID_QBMRelationBase , XTouched ) select rn.RelationID , rn.UID_QBMRelation , rn.UID_ParentColumn68 , rn.ParentRestriction , rn.ParentExecuteBy , rn.ParentAllowUpdate , rn.UID_ChildColumn , rn.ChildRestriction , rn.ChildExecuteBy , rn.ChildAllowUpdate69 , @Xdate, @Xdate, @XUser, @XUser , dbo.QBM_FCVElementToObjectKey1('QBMRelation', 'UID_QBMRelation', rn.UID_QBMRelation) , rn.UID_QBMRelationBase , 'I'70 from @QBMRelation rn where Not exists (select top 1 1 from QBMRelation re where re.UID_QBMRelation = rn.UID_QBMRelation ) select @CountItems = @@ROWCOUNT71 if @DebugSwitch > 0 begin print 'Zeilen eingefügt ' + str(@CountItems) end END TRY BEGIN CATCH exec QBM_PSessionErrorAdd default declare @Rethrow varchar72(1000) = dbo.QBM_FGISessionErrorRethrow() RAISERROR (@Rethrow, 18, 1) WITH NOWAIT END CATCH endLabel: end 73