dbo.QBM_PDBQueueReplGenProcID
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_FCVStringToInt source text reference
- references source dbo.QBM_FGIConfigparmValue source text reference
- references source dbo.QBM_FGISessionErrorIsDeadlock source text reference
- references source dbo.QBM_PDBQCS_CurrentMoveSlot source text reference
- references source dbo.QBM_PProcessCreate source text reference
- references source dbo.QBM_PSessionErrorAdd source text reference
- references source dbo.QBM_PSessionErrorClean source text reference
- references source dbo.QBM_PWaitForSeconds source text reference
Complete Source
1CREATE PROCEDURE QBM_PDBQueueReplGenProcID(2 @UID_Task varchar(38),3 @SlotNumber int,4 @ExecutionType int,5 @CountParameter int6)7AS8BEGIN9 DECLARE @object varchar(38)10 DECLARE @SubObject varchar(38)11 DECLARE @GenProcIDNew varchar(38)12 DECLARE @GenProcIDFallBack varchar(38) = newid()13 DECLARE @AnzahlInGruppe int14 DECLARE @Doppelte QBM_YMNTable15 DECLARE @ReplaceLimit int16 DECLARE @Compresslimit int17 DECLARE @CountItems int18 DECLARE @DebugSwitch int = 019 DECLARE @deadlockcounter int20 DECLARE @waittime float21 DECLARE @ElementBuffer QBM_YCursorBuffer22 DECLARE @ElementCount int23 DECLARE @ElementIndex int24 DECLARE @Repair QBM_YHelperQueueRepair25 DECLARE @Substitute QBM_YHelperQueueSubstitute26 DECLARE @SlotNumberSource int27 DECLARE @SlotNumberTarget int28 DECLARE @DBQueueToMove QBM_YDBQCSCurrentToMove29 DECLARE @RowsMoved int30 SET XACT_ABORT OFF31 BEGIN TRY32 SELECT33 @waittime = convert(float,34 @SlotNumber) * 0.1535 IF @DebugSwitch > 036 BEGIN37 print 'im replacer angekommen, Trancount ' + str(@@trancount) print 'aktives Slot ' + str(@slotnumber)38 END39 SELECT40 @ReplaceLimit = dbo.QBM_FCVStringToInt(dbo.QBM_FGIConfigparmValue('QBM\DBQueue\GenProcIDReplaceLimit'),41 6)42 IF @@rowcount = 043 BEGIN44 GOTO ende45 END46 IF '' = dbo.QBM_FGIConfigparmValue('Common\ProcessState')47 BEGIN48 SELECT @compresslimit = 149 END50 ELSE51 BEGIN52 SELECT @compresslimit = @ReplaceLimit53 END54 DELETE @Repair55 IF @DebugSwitch > 056 BEGIN57 print 'ReplGenProcID vor Doppelte :' + nchar(9) + convert(nvarchar(64),58 GETUTCDATE(),59 121)60 END61 IF @countparameter = 062 BEGIN63 INSERT INTO @Doppelte(UID_Element1,64 UID_Element2,65 XOrigin)66 SELECT67 '' AS object,68 '' AS subobject,69 CountItems70 FROM(71 SELECT Count(*) AS CountItems72 FROM QBMDBQueueCurrent73 WITH(readpast)74 WHERE75 SlotNumber = @SlotNumber) AS x76 WHERE77 x.CountItems > 178 SELECT @CountItems = @@rowcount79 IF @DebugSwitch > 080 BEGIN81 print 'doppelte ermittelt für Parameter 0, Stückzahl ' + str(@CountItems)82 END83 END84 IF @countparameter = 185 BEGIN86 INSERT INTO @Doppelte(UID_Element1,87 UID_Element2,88 XOrigin)89 SELECT90 isnull(uid_parameter,91 '') AS object,92 '' AS subobject,93 CountItems94 FROM(95 SELECT96 uid_parameter,97 Count(*) AS CountItems98 FROM QBMDBQueueCurrent99 WITH(readpast)100 WHERE101 SlotNumber = @SlotNumber102 GROUP BY uid_parameter103 HAVING count(*) > 1) AS x104 SELECT @CountItems = @@rowcount105 IF @DebugSwitch > 0106 BEGIN107 print 'doppelte ermittelt für Parameter 1, Stückzahl ' + str(@CountItems)108 END109 END110 IF @countparameter = 2111 BEGIN112 INSERT INTO @Doppelte(UID_Element1,113 UID_Element2,114 XOrigin)115 SELECT116 uid_parameter AS object,117 uid_SubParameter AS subobject,118 CountItems119 FROM(120 SELECT121 uid_parameter,122 uid_Subparameter,123 Count(*) AS CountItems124 FROM QBMDBQueueCurrent125 WITH(readpast)126 WHERE127 SlotNumber = @SlotNumber128 GROUP BY uid_parameter,129 uid_SubParameter130 HAVING count(*) > 1) AS x131 SELECT @CountItems = @@rowcount132 IF @DebugSwitch > 0133 BEGIN134 print 'doppelte ermittelt für Parameter 2, Stückzahl ' + str(@CountItems)135 END136 END137 IF @CountItems = 0138 BEGIN139 IF @DebugSwitch > 0140 BEGIN141 print 'ReplGenProcID keine Doppelte :' + nchar(9) + convert(nvarchar(64),142 GETUTCDATE(),143 121)144 END145 GOTO ende146 END147 IF @DebugSwitch > 0148 BEGIN149 print 'ReplGenProcID nach Doppelte :' + nchar(9) + convert(nvarchar(64),150 GETUTCDATE(),151 121)152 END153 IF @countParameter = 0154 BEGIN155 INSERT INTO @Repair(UID_DialogDBQueue,156 object,157 subobject,158 GenProcIDNew,159 GenProcIDOrigin,160 Xtouched,161 Generation)162 SELECT163 q.UID_DialogDBQueue,164 '',165 '',166 '',167 CASE168 WHEN isnull(q.GenProcID,169 '') = '' THEN170 @GenProcIDFallBack171 ELSE q.GenProcID172 END,173 '',174 q.Generation175 FROM QBMDBQueueCurrent q176 WITH(readpast)177 JOIN @Doppelte x178 ON q.SlotNumber = @SlotNumber option(maxdop 1)179 SELECT @CountItems = @@rowcount180 END181 IF @countParameter = 1182 BEGIN183 INSERT INTO @Repair(UID_DialogDBQueue,184 object,185 subobject,186 GenProcIDNew,187 GenProcIDOrigin,188 Xtouched,189 Generation)190 SELECT191 q.UID_DialogDBQueue,192 x.UID_Element1,193 '',194 '',195 CASE196 WHEN isnull(q.GenProcID,197 '') = '' THEN198 @GenProcIDFallBack199 ELSE q.GenProcID200 END,201 '',202 q.Generation203 FROM QBMDBQueueCurrent q204 WITH(readpast)205 JOIN @Doppelte x206 ON x.UID_Element1 = isnull(q.uid_parameter,207 '') collate database_default AND q.SlotNumber = @SlotNumber option(maxdop 1)208 SELECT @CountItems = @@rowcount209 END210 IF @countParameter = 2211 BEGIN212 INSERT INTO @Repair(UID_DialogDBQueue,213 object,214 subobject,215 GenProcIDNew,216 GenProcIDOrigin,217 Xtouched,218 Generation)219 SELECT220 q.UID_DialogDBQueue,221 x.UID_Element1,222 x.UID_Element2,223 '',224 CASE225 WHEN isnull(q.GenProcID,226 '') = '' THEN227 @GenProcIDFallBack228 ELSE q.GenProcID229 END,230 '',231 q.Generation232 FROM QBMDBQueueCurrent q233 WITH(readpast)234 JOIN @Doppelte x235 ON x.UID_Element1 = isnull(q.uid_parameter,236 '') collate database_default AND x.UID_Element2 = isnull(q.uid_subparameter,237 '') collate database_default AND q.SlotNumber = @SlotNumber option(maxdop 1)238 SELECT @CountItems = @@rowcount239 END240 IF @CountItems = 0241 BEGIN242 IF @DebugSwitch > 0243 BEGIN244 print 'Replace keine Gruppen gefunden:' + convert(nvarchar(64),245 GETUTCDATE(),246 121)247 END248 GOTO ende249 END250 SELECT @deadlockcounter = 150251 WHILE @deadlockcounter > 0252 BEGIN253 BEGIN TRY254 SELECT @SlotNumberSource = @SlotNumber255 SELECT @SlotnumberTarget = 0256 DELETE @DBQueueToMove257 INSERT INTO @DBQueueToMove(UID_DialogDBQueue)258 SELECT cul.UID_DialogDBQueue259 FROM @Repair cul260 EXEC @RowsMoved = QBM_PDBQCS_CurrentMoveSlot @DBQueueToMove,261 @SlotNumberSource,262 @SlotnumberTarget263 SELECT @deadlockcounter = 0264 END TRY265 BEGIN CATCH266 EXEC QBM_PSessionErrorAdd DEFAULT267 IF dbo.QBM_FGISessionErrorIsDeadlock(DEFAULT) = 1268 BEGIN269 EXEC QBM_PWaitForSeconds @waittime270 SELECT @deadlockcounter -= 1271 END272 ELSE273 BEGIN274 RAISERROR('',275 18,276 1)277 WITH NOWAIT278 END279 END CATCH280 END281 EXEC QBM_PSessionErrorClean282 DELETE @Substitute283 INSERT INTO @Substitute(GenProcIDOrigin,284 GenProcIDNew)285 SELECT286 GenProcIDOrigin,287 GenProcIDNew288 FROM DialogProcessSubstitute s289 WHERE290 EXISTS(291 SELECT TOP 1 1292 FROM @Repair r293 WHERE294 s.GenProcIDOrigin = r.GenProcIDOrigin) OR EXISTS(295 SELECT TOP 1 1296 FROM @Repair r297 WHERE298 s.GenProcIDNew = r.GenProcIDOrigin) option(maxdop 1)299 IF @DebugSwitch > 0300 BEGIN301 print 'DialogProcessSubstitute initialbefüllung'302 END303 INSERT INTO @Substitute(GenProcIDOrigin,304 GenProcIDNew)305 SELECT306 GenProcIDOrigin,307 GenProcIDNew308 FROM DialogProcessSubstitute s309 WHERE310 EXISTS(311 SELECT TOP 1 1312 FROM @Substitute sx313 WHERE314 sx.GenProcIDNew = s.GenProcIDNew) AND NOT EXISTS(315 SELECT TOP 1 1316 FROM @Substitute x317 WHERE318 x.GenProcIDOrigin = s.GenProcIDOrigin AND x.GenProcIDNew = s.GenProcIDNew)319 UPDATE @Substitute320 SET CountOrigin = x.CountItems321 FROM @Substitute s,322 (323 SELECT324 GenProcIDNew,325 count(*) AS CountItems326 FROM @Substitute327 GROUP BY GenProcIDNew) AS x328 WHERE329 s.GenProcIDNew = x.GenProcIDNew330 IF @DebugSwitch > 0331 BEGIN332 print ' vor Substitute-Anwendung'333 END334 IF @CountParameter = 0335 BEGIN336 INSERT INTO @Repair(UID_DialogDBQueue,337 object,338 subobject,339 GenProcIDNew,340 GenProcIDOrigin,341 Xtouched,342 Generation)343 SELECT344 newid(),345 x.object,346 x.subobject,347 x.GenProcIDNew,348 x.GenProcIDOrigin,349 '',350 x.Generation351 FROM(352 SELECT353 '' AS object,354 '' AS subobject,355 '' AS GenProcIDNew,356 s.GenProcIDOrigin,357 MAX(r.Generation) AS Generation358 FROM @Repair r359 JOIN @Substitute s360 ON r.GenProcIDOrigin = s.GenProcIDNew361 WHERE362 NOT EXISTS(363 SELECT TOP 1 1364 FROM @Repair r2365 WHERE366 r2.GenProcIDOrigin = s.GenProcIDOrigin)367 GROUP BY s.GenProcIDOrigin) AS x option(maxdop 1)368 END369 IF @CountParameter = 1370 BEGIN371 INSERT INTO @Repair(UID_DialogDBQueue,372 object,373 subobject,374 GenProcIDNew,375 GenProcIDOrigin,376 Xtouched,377 Generation)378 SELECT379 newid(),380 x.object,381 x.subobject,382 x.GenProcIDNew,383 x.GenProcIDOrigin,384 '',385 x.Generation386 FROM(387 SELECT388 r.object,389 '' AS subobject,390 '' AS GenProcIDNew,391 s.GenProcIDOrigin,392 MAX(r.Generation) AS Generation393 FROM @Repair r394 JOIN @Substitute s395 ON r.GenProcIDOrigin = s.GenProcIDNew396 WHERE397 NOT EXISTS(398 SELECT TOP 1 1399 FROM @Repair r2400 WHERE401 r2.object = r.object AND r2.GenProcIDOrigin = s.GenProcIDOrigin)402 GROUP BY r.object,403 s.GenProcIDOrigin) AS x option(maxdop 1)404 END405 IF @CountParameter = 2406 BEGIN407 INSERT INTO @Repair(UID_DialogDBQueue,408 object,409 subobject,410 GenProcIDNew,411 GenProcIDOrigin,412 Xtouched,413 Generation)414 SELECT415 newid(),416 x.object,417 x.subobject,418 x.GenProcIDNew,419 x.GenProcIDOrigin,420 '',421 x.Generation422 FROM(423 SELECT424 r.object,425 r.subobject,426 '' AS GenProcIDNew,427 s.GenProcIDOrigin,428 MAX(r.Generation) AS Generation429 FROM @Repair r430 JOIN @Substitute s431 ON r.GenProcIDOrigin = s.GenProcIDNew432 WHERE433 NOT EXISTS(434 SELECT TOP 1 1435 FROM @Repair r2436 WHERE437 r2.object = r.object AND r2.subobject = r.subobject AND r2.GenProcIDOrigin = s.GenProcIDOrigin)438 GROUP BY r.object,439 r.subobject,440 s.GenProcIDOrigin) AS x option(maxdop 1)441 END442 IF @DebugSwitch > 0443 BEGIN444 print ' nach Substitute-Anwendung'445 END446 UPDATE @Repair447 SET GenProcIDNew = '',448 GenProcIDOrigin = s.GenProcIDOrigin449 FROM @Repair r450 JOIN @Substitute s451 ON r.GenProcIDOrigin = s.GenProcIDNew option(maxdop 1)452 IF @DebugSwitch > 0453 BEGIN454 print ' nach Update-Anwendung'455 END456 IF @CountParameter = 0457 BEGIN458 IF EXISTS(459 SELECT TOP 1 1460 FROM @Repair461 GROUP BY GenProcIDorigin462 HAVING count(*) > 1)463 BEGIN464 DELETE @Repair465 FROM @Repair qr,466 (467 SELECT468 min(uid_dialogdbqueue) AS uid_dialogdbqueue,469 GenProcIDOrigin470 FROM @Repair471 GROUP BY GenProcIDorigin472 HAVING count(*) > 1) AS x473 WHERE474 qr.GenProcIDorigin = x.GenProcIDorigin AND qr.uid_dialogdbqueue <> x.uid_dialogdbqueue475 END476 END477 IF @CountParameter = 1478 BEGIN479 IF EXISTS(480 SELECT TOP 1 1481 FROM @Repair482 GROUP BY object,483 GenProcIDorigin484 HAVING count(*) > 1)485 BEGIN486 DELETE @Repair487 FROM @Repair qr,488 (489 SELECT490 min(uid_dialogdbqueue) AS uid_dialogdbqueue,491 object,492 GenProcIDOrigin493 FROM @Repair494 GROUP BY object,495 GenProcIDorigin496 HAVING count(*) > 1) AS x497 WHERE498 qr.Object = x.object AND qr.GenProcIDOrigin = x.GenProcIDorigin AND qr.uid_dialogdbqueue <> x.uid_dialogdbqueue499 END500 END501 IF @CountParameter = 2502 BEGIN503 IF EXISTS(504 SELECT TOP 1 1505 FROM @Repair506 GROUP BY object,507 subobject,508 GenProcIDorigin509 HAVING count(*) > 1)510 BEGIN511 DELETE @Repair512 FROM @Repair qr,513 (514 SELECT515 min(uid_dialogdbqueue) AS uid_dialogdbqueue,516 object,517 subobject,518 GenProcIDOrigin519 FROM @Repair520 GROUP BY object,521 subobject,522 GenProcIDorigin523 HAVING count(*) > 1) AS x524 WHERE525 qr.object = x.object AND qr.subobject = x.subobject AND qr.GenProcIDorigin = x.GenProcIDorigin AND qr.uid_dialogdbqueue <> x.uid_dialogdbqueue526 END527 END528 IF @CountParameter = 0529 BEGIN530 DELETE @Repair531 FROM @Repair qr,532 (533 SELECT534 min(uid_dialogdbqueue) AS uid_dialogdbqueue,535 count(*) AS CountItems536 FROM @Repair) AS x537 WHERE538 x.CountItems > @compresslimit AND qr.uid_dialogdbqueue <> x.uid_dialogdbqueue539 END540 IF @CountParameter = 1541 BEGIN542 DELETE @Repair543 FROM @Repair qr,544 (545 SELECT546 min(uid_dialogdbqueue) AS uid_dialogdbqueue,547 object548 FROM @Repair549 GROUP BY object550 HAVING count(*) > @compresslimit) AS x551 WHERE552 qr.object = x.object AND qr.uid_dialogdbqueue <> x.uid_dialogdbqueue553 END554 IF @CountParameter = 2555 BEGIN556 DELETE @Repair557 FROM @Repair qr,558 (559 SELECT560 min(uid_dialogdbqueue) AS uid_dialogdbqueue,561 object,562 subobject563 FROM @Repair564 GROUP BY object,565 subobject566 HAVING count(*) > @compresslimit) AS x567 WHERE568 qr.object = x.object AND qr.subobject = x.subobject AND qr.uid_dialogdbqueue <> x.uid_dialogdbqueue569 END570 UPDATE @Repair571 SET Xtouched = ''572 IF @CountParameter = 0573 BEGIN574 IF 1 =(575 SELECT count(*)576 FROM @Repair)577 BEGIN578 UPDATE @Repair579 SET XTouched = 'D'580 INSERT INTO QBMDBQueueCurrent(UID_DialogDBQueue,581 UID_Parameter,582 uid_SubParameter,583 GenProcID,584 SlotNumber,585 UID_Task,586 Generation,587 StartedAt)588 SELECT589 newid(),590 '',591 '',592 CASE593 WHEN isnull(r.GenProcIDOrigin,594 '') = '' THEN595 @GenProcIDFallBack596 ELSE r.GenProcIDOrigin597 END,598 @SlotNumber,599 @UID_Task,600 r.Generation,601 GETUTCDATE()602 FROM @Repair r603 WHERE604 xtouched = 'D' option(maxdop 1)605 END606 END607 IF @CountParameter = 1608 BEGIN609 UPDATE @Repair610 SET XTouched = 'D'611 WHERE612 UID_DialogDBQueue IN(613 SELECT min(r.UID_DialogDBQueue) AS UID_DialogDBQueue614 FROM @Repair r615 GROUP BY r.object616 HAVING count(*) = 1) option(maxdop 1)617 INSERT INTO QBMDBQueueCurrent(UID_DialogDBQueue,618 UID_Parameter,619 uid_SubParameter,620 GenProcID,621 SlotNumber,622 UID_Task,623 Generation,624 StartedAt)625 SELECT626 newid(),627 r.object,628 '',629 CASE630 WHEN isnull(r.GenProcIDOrigin,631 '') = '' THEN632 @GenProcIDFallBack633 ELSE r.GenProcIDOrigin634 END,635 @SlotNumber,636 @UID_Task,637 r.Generation,638 GETUTCDATE()639 FROM @Repair r640 WHERE641 xtouched = 'D' option(maxdop 1)642 END643 IF @CountParameter = 2644 BEGIN645 UPDATE @Repair646 SET XTouched = 'D'647 WHERE648 UID_DialogDBQueue IN(649 SELECT min(r.UID_DialogDBQueue) AS UID_DialogDBQueue650 FROM @Repair r651 GROUP BY r.object,652 r.subobject653 HAVING count(*) = 1) option(maxdop 1)654 INSERT INTO QBMDBQueueCurrent(UID_DialogDBQueue,655 UID_Parameter,656 uid_SubParameter,657 GenProcID,658 SlotNumber,659 UID_Task,660 Generation,661 StartedAt)662 SELECT663 newid(),664 r.object,665 r.SubObject,666 CASE667 WHEN isnull(r.GenProcIDOrigin,668 '') = '' THEN669 @GenProcIDFallBack670 ELSE r.GenProcIDOrigin671 END,672 @SlotNumber,673 @UID_Task,674 r.Generation,675 GETUTCDATE()676 FROM @Repair r677 WHERE678 xtouched = 'D' option(maxdop 1)679 END680 DELETE @Repair681 WHERE682 xtouched = 'D'683 IF @countParameter = 0684 BEGIN685 INSERT INTO @ElementBuffer(UID1,686 UID2,687 int1)688 SELECT689 '' AS object,690 '' AS SubObject,691 count(*) AS CountItems692 FROM @Repair693 WHERE694 xtouched = ''695 SELECT @ElementCount = @@ROWCOUNT696 END697 IF @countParameter = 1698 BEGIN699 INSERT INTO @ElementBuffer(UID1,700 UID2,701 int1)702 SELECT703 object,704 '' AS SubObject,705 count(*) AS CountItems706 FROM @Repair707 WHERE708 xtouched = ''709 GROUP BY object710 SELECT @ElementCount = @@ROWCOUNT711 END712 IF @countParameter = 2713 BEGIN714 INSERT INTO @ElementBuffer(UID1,715 UID2,716 int1)717 SELECT718 object,719 SubObject,720 count(*) AS CountItems721 FROM @Repair722 WHERE723 xtouched = ''724 GROUP BY object,725 SubObject726 SELECT @ElementCount = @@ROWCOUNT727 END728 SELECT @ElementIndex = 1729 WHILE @ElementIndex <= @ElementCount730 BEGIN731 SELECT732 TOP 1 @object = bu.UID1,733 @Subobject = bu.UID2,734 @AnzahlInGruppe = bu.Int1735 FROM @ElementBuffer bu736 WHERE737 bu.ElementIndex = @ElementIndex738 IF @DebugSwitch > 0739 BEGIN740 print ' im Zyklus @Repair' + @object + @Subobject + str(@AnzahlInGruppe)741 END742 SELECT @GenProcIDNew = NULL743 IF @CountParameter = 0744 BEGIN745 SELECT TOP 1 @GenProcIDNew = s.GenProcIDNew746 FROM @Substitute s747 LEFT748 OUTER749 JOIN @Repair q750 ON s.GenProcIDOrigin = q.GenProcIDOrigin751 WHERE752 s.CountOrigin = @AnzahlInGruppe753 END754 IF @CountParameter = 1755 BEGIN756 SELECT TOP 1 @GenProcIDNew = s.GenProcIDNew757 FROM @Substitute s758 LEFT759 OUTER760 JOIN @Repair q761 ON s.GenProcIDOrigin = q.GenProcIDOrigin762 WHERE763 s.CountOrigin = @AnzahlInGruppe AND q.object = @Object764 GROUP BY s.GenProcIDNew765 HAVING count(DISTINCT isnull(q.object, '#')) = 1766 END767 IF @CountParameter = 2768 BEGIN769 SELECT TOP 1 @GenProcIDNew = s.GenProcIDNew770 FROM @Substitute s771 LEFT772 OUTER773 JOIN @Repair q774 ON s.GenProcIDOrigin = q.GenProcIDOrigin775 WHERE776 s.CountOrigin = @AnzahlInGruppe AND q.object = @Object AND q.Subobject = @SubObject777 GROUP BY s.GenProcIDNew778 HAVING count(DISTINCT isnull(q.object, '#') + isnull(q.Subobject, '#')) = 1779 END780 IF @GenProcIDNew IS NULL781 BEGIN782 SELECT @GenProcIDNew = newid()783 EXEC QBM_PProcessCreate @GenProcIDNew,784 'DBScheduler',785 @DisplayName = 'DialogProcessSubstitute'786 INSERT INTO DialogProcessSubstitute(GenProcIDNew,787 GenProcIDOrigin,788 ReadyForDeleteOrExport)789 SELECT790 DISTINCT @GenProcIDNew,791 GenProcIDOrigin,792 0793 FROM @Repair794 WHERE795 object = @object AND subobject = @Subobject AND isnull(XTouched,796 '') <> 'D'797 INSERT INTO @Substitute(GenProcIDNew,798 GenProcIDOrigin,799 CountOrigin)800 SELECT801 DISTINCT @GenProcIDNew,802 GenProcIDOrigin,803 @AnzahlInGruppe804 FROM @Repair805 WHERE806 object = @object AND subobject = @Subobject AND isnull(XTouched,807 '') <> 'D'808 IF @DebugSwitch > 0809 BEGIN810 print 'neue @GenProcIDNew vergeben'811 END812 END813 IF @CountParameter = 0814 BEGIN815 UPDATE @Repair816 SET GenProcIDNew = @GenProcIDNew817 WHERE818 isnull(GenProcIDNew,819 '') <> @GenProcIDNew820 END821 IF @CountParameter = 1822 BEGIN823 UPDATE @Repair824 SET GenProcIDNew = @GenProcIDNew825 WHERE826 object = @object AND isnull(GenProcIDNew,827 '') <> @GenProcIDNew828 END829 IF @CountParameter = 2830 BEGIN831 UPDATE @Repair832 SET GenProcIDNew = @GenProcIDNew833 WHERE834 object = @object AND subobject = @Subobject AND isnull(GenProcIDNew,835 '') <> @GenProcIDNew836 END837 SELECT @ElementIndex += 1838 END839 IF @DebugSwitch > 0840 BEGIN841 print 'durchgerechnet'842 END843 IF @countParameter = 0844 BEGIN845 INSERT INTO QBMDBQueueCurrent(UID_DialogDBQueue,846 UID_Parameter,847 uid_SubParameter,848 GenProcID,849 SlotNumber,850 UID_Task,851 Generation,852 StartedAt)853 SELECT854 newid(),855 '',856 '',857 CASE858 WHEN isnull(x.GenProcIDNew,859 '') = '' THEN860 @GenProcIDFallBack861 ELSE x.GenProcIDNew862 END,863 @SlotNumber,864 @UID_Task,865 x.Generation,866 GETUTCDATE()867 FROM(868 SELECT869 r.GenProcIDNew,870 MAX(r.Generation) AS Generation871 FROM @Repair r872 GROUP BY GenProcIDNew) AS x option(maxdop 1)873 END874 IF @countParameter = 1875 BEGIN876 INSERT INTO QBMDBQueueCurrent(UID_DialogDBQueue,877 UID_Parameter,878 uid_SubParameter,879 GenProcID,880 SlotNumber,881 UID_Task,882 Generation,883 StartedAt)884 SELECT885 newid(),886 x.object,887 '',888 CASE889 WHEN isnull(x.GenProcIDNew,890 '') = '' THEN891 @GenProcIDFallBack892 ELSE x.GenProcIDNew893 END,894 @SlotNumber,895 @UID_Task,896 x.Generation,897 GETUTCDATE()898 FROM(899 SELECT900 object,901 GenProcIDNew,902 MAX(r.Generation) AS Generation903 FROM @Repair r904 GROUP BY object,905 GenProcIDNew) AS x option(maxdop 1)906 END907 IF @countParameter = 2908 BEGIN909 INSERT INTO QBMDBQueueCurrent(UID_DialogDBQueue,910 UID_Parameter,911 uid_SubParameter,912 GenProcID,913 SlotNumber,914 UID_Task,915 Generation,916 StartedAt)917 SELECT918 newid(),919 x.object,920 x.subobject,921 CASE922 WHEN isnull(x.GenProcIDNew,923 '') = '' THEN924 @GenProcIDFallBack925 ELSE x.GenProcIDNew926 END,927 @SlotNumber,928 @UID_Task,929 x.Generation,930 GETUTCDATE()931 FROM(932 SELECT933 object,934 subobject,935 GenProcIDNew,936 max(r.Generation) AS Generation937 FROM @Repair r938 GROUP BY object,939 subobject,940 GenProcIDNew) AS x option(maxdop 1)941 END942 END TRY943 BEGIN CATCH944 EXEC QBM_PSessionErrorAdd DEFAULT945 RAISERROR('',946 18,947 1)948 WITH NOWAIT949 END CATCH950 IF @DebugSwitch > 0951 BEGIN952 print 'replacer kurz vor Ende, Trancount ' + str(@@trancount)953 END954 ende:955 IF @DebugSwitch > 0956 BEGIN957 print 'ReplGenProcID Ende :' + nchar(9) + convert(nvarchar(64),958 GETUTCDATE(),959 121)960 END961 RETURN962END
Open raw exported source
1 create procedure QBM_PDBQueueReplGenProcID (@UID_Task varchar(38) , @SlotNumber int , @ExecutionType int , @CountParameter int ) as 2begin declare @object varchar(38) declare @SubObject varchar(38) declare @GenProcIDNew varchar(38) declare @GenProcIDFallBack varchar(38) = newid() declare3 @AnzahlInGruppe int declare @Doppelte QBM_YMNTable declare @ReplaceLimit int declare @Compresslimit int declare @CountItems int declare @DebugSwitch4 int = 0 declare @deadlockcounter int declare @waittime float declare @ElementBuffer QBM_YCursorBuffer declare @ElementCount int declare @ElementIndex5 int declare @Repair QBM_YHelperQueueRepair declare @Substitute QBM_YHelperQueueSubstitute declare @SlotNumberSource int declare @SlotNumberTarget int 6declare @DBQueueToMove QBM_YDBQCSCurrentToMove declare @RowsMoved int SET XACT_ABORT OFF BEGIN TRY select @waittime = convert(float, @SlotNumber) * 0.157 if @DebugSwitch > 0 begin print 'im replacer angekommen, Trancount ' + str(@@trancount) print 'aktives Slot ' + str(@slotnumber) end select @ReplaceLimit8 = dbo.QBM_FCVStringToInt(dbo.QBM_FGIConfigparmValue('QBM\DBQueue\GenProcIDReplaceLimit'), 6) if @@rowcount = 0 begin goto ende end if '' = dbo.QBM_FGIConfigparmValue9 ('Common\ProcessState') begin select @compresslimit = 1 end else begin select @compresslimit = @ReplaceLimit end delete @Repair if @DebugSwitch 10> 0 begin print 'ReplGenProcID vor Doppelte :' + nchar(9) + convert(nvarchar(64), GETUTCDATE(), 121) end if @countparameter = 0 begin insert into @Doppelte11 (UID_Element1 , UID_Element2 , XOrigin ) select '' as object , '' as subobject , CountItems from ( select Count(*) as CountItems from QBMDBQueueCurrent12 with (readpast) where SlotNumber = @SlotNumber ) as x where x.CountItems > 1 select @CountItems = @@rowcount if @DebugSwitch > 0 begin print 'doppelte ermittelt für Parameter 0, Stückzahl '13 + str(@CountItems) end end if @countparameter = 1 begin insert into @Doppelte (UID_Element1 , UID_Element2 , XOrigin ) select isnull(uid_parameter, ''14) as object , '' as subobject , CountItems from ( select uid_parameter , Count(*) as CountItems from QBMDBQueueCurrent with (readpast) where SlotNumber15 = @SlotNumber group by uid_parameter having count(*) > 1 ) as x select @CountItems = @@rowcount if @DebugSwitch > 0 begin print 'doppelte ermittelt für Parameter 1, Stückzahl '16 + str(@CountItems) end end if @countparameter = 2 begin insert into @Doppelte (UID_Element1 , UID_Element2 , XOrigin ) select uid_parameter as object 17, uid_SubParameter as subobject , CountItems from ( select uid_parameter , uid_Subparameter, Count(*) as CountItems from QBMDBQueueCurrent with (readpast18) where SlotNumber = @SlotNumber group by uid_parameter, uid_SubParameter having count(*) > 1 ) as x select @CountItems = @@rowcount if @DebugSwitch >19 0 begin print 'doppelte ermittelt für Parameter 2, Stückzahl ' + str(@CountItems) end end if @CountItems = 0 begin if @DebugSwitch > 0 begin print 'ReplGenProcID keine Doppelte :'20 + nchar(9) + convert(nvarchar(64), GETUTCDATE(), 121) end goto ende end if @DebugSwitch > 0 begin print 'ReplGenProcID nach Doppelte :' + nchar(9) + convert21(nvarchar(64), GETUTCDATE(), 121) end if @countParameter = 0 begin insert into @Repair (UID_DialogDBQueue, object, subobject, GenProcIDNew , GenProcIDOrigin22, Xtouched, Generation ) select q.UID_DialogDBQueue, '', '', '' , case when isnull(q.GenProcID,'') = '' then @GenProcIDFallBack else q.GenProcID end , 23'' , q.Generation from QBMDBQueueCurrent q with (readpast) join @Doppelte x on q.SlotNumber = @SlotNumber option (maxdop 1) select @CountItems = @@rowcount24 end if @countParameter = 1 begin insert into @Repair (UID_DialogDBQueue, object, subobject, GenProcIDNew , GenProcIDOrigin, Xtouched, Generation ) select25 q.UID_DialogDBQueue, x.UID_Element1 , '', '' , case when isnull(q.GenProcID,'') = '' then @GenProcIDFallBack else q.GenProcID end , '' , q.Generation 26from QBMDBQueueCurrent q with (readpast) join @Doppelte x on x.UID_Element1 = isnull(q.uid_parameter,'') collate database_default and q.SlotNumber = @SlotNumber27 option (maxdop 1) select @CountItems = @@rowcount end if @countParameter = 2 begin insert into @Repair (UID_DialogDBQueue, object, subobject, GenProcIDNew28 , GenProcIDOrigin, Xtouched, Generation ) select q.UID_DialogDBQueue, x.UID_Element1 , x.UID_Element2 , '' , case when isnull(q.GenProcID,'') = '' then29 @GenProcIDFallBack else q.GenProcID end , '' , q.Generation from QBMDBQueueCurrent q with (readpast) join @Doppelte x on x.UID_Element1 = isnull(q.uid_parameter30,'') collate database_default and x.UID_Element2 = isnull(q.uid_subparameter,'') collate database_default and q.SlotNumber = @SlotNumber option (maxdop31 1) select @CountItems = @@rowcount end if @CountItems = 0 begin if @DebugSwitch > 0 begin print 'Replace keine Gruppen gefunden:' + convert(nvarchar(6432), GETUTCDATE(), 121) end goto ende end select @deadlockcounter = 150 while @deadlockcounter > 0 begin BEGIN TRY select @SlotNumberSource = @SlotNumber33 select @SlotnumberTarget = 0 delete @DBQueueToMove insert into @DBQueueToMove(UID_DialogDBQueue) select cul.UID_DialogDBQueue from @Repair cul exec 34@RowsMoved = QBM_PDBQCS_CurrentMoveSlot @DBQueueToMove, @SlotNumberSource, @SlotnumberTarget select @deadlockcounter = 0 END TRY BEGIN CATCH exec35 QBM_PSessionErrorAdd default if dbo.QBM_FGISessionErrorIsDeadlock(default) = 1 begin exec QBM_PWaitForSeconds @waittime select @deadlockcounter -= 1 end36 else begin RAISERROR ('', 18, 1) WITH NOWAIT end END CATCH end exec QBM_PSessionErrorClean delete @Substitute insert into @Substitute (GenProcIDOrigin37, GenProcIDNew) select GenProcIDOrigin, GenProcIDNew from DialogProcessSubstitute s where exists (select top 1 1 from @Repair r where s.GenProcIDOrigin38 = r.GenProcIDOrigin ) or exists (select top 1 1 from @Repair r where s.GenProcIDNew = r.GenProcIDOrigin ) option (maxdop 1) if @DebugSwitch > 0 begin39 print 'DialogProcessSubstitute initialbefüllung' end insert into @Substitute (GenProcIDOrigin, GenProcIDNew) select GenProcIDOrigin, GenProcIDNew from40 DialogProcessSubstitute s where exists ( select top 1 1 from @Substitute sx where sx.GenProcIDNew = s.GenProcIDNew ) and not exists (select top 1 1 from41 @Substitute x where x.GenProcIDOrigin = s.GenProcIDOrigin and x.GenProcIDNew = s.GenProcIDNew ) update @Substitute set CountOrigin = x.CountItems from42 @Substitute s, ( select GenProcIDNew , count(*) as CountItems from @Substitute group by GenProcIDNew ) as x where s.GenProcIDNew = x.GenProcIDNew if 43@DebugSwitch > 0 begin print ' vor Substitute-Anwendung' end if @CountParameter = 0 begin insert into @Repair (UID_DialogDBQueue, object, subobject, GenProcIDNew44, GenProcIDOrigin, Xtouched, Generation ) select newid(), x.object, x.subobject, x.GenProcIDNew, x.GenProcIDOrigin, '', x.Generation from ( select '' as45 object, '' as subobject , '' as GenProcIDNew, s.GenProcIDOrigin, MAX(r.Generation) as Generation from @Repair r join @Substitute s on r.GenProcIDOrigin46 = s.GenProcIDNew where Not exists (select top 1 1 from @Repair r2 where r2.GenProcIDOrigin = s.GenProcIDOrigin ) group by s.GenProcIDOrigin ) as x option47 (maxdop 1) end if @CountParameter = 1 begin insert into @Repair (UID_DialogDBQueue, object, subobject, GenProcIDNew, GenProcIDOrigin, Xtouched, Generation48 ) select newid(), x.object, x.subobject, x.GenProcIDNew, x.GenProcIDOrigin, '', x.Generation from ( select r.object, '' as subobject , '' as GenProcIDNew49, s.GenProcIDOrigin, MAX(r.Generation) as Generation from @Repair r join @Substitute s on r.GenProcIDOrigin = s.GenProcIDNew where Not exists (select top50 1 1 from @Repair r2 where r2.object = r.object and r2.GenProcIDOrigin = s.GenProcIDOrigin ) group by r.object, s.GenProcIDOrigin ) as x option (maxdop51 1) end if @CountParameter = 2 begin insert into @Repair (UID_DialogDBQueue, object, subobject, GenProcIDNew, GenProcIDOrigin, Xtouched, Generation ) select52 newid(), x.object, x.subobject, x.GenProcIDNew, x.GenProcIDOrigin, '', x.Generation from ( select r.object, r.subobject, '' as GenProcIDNew, s.GenProcIDOrigin53, MAX(r.Generation) as Generation from @Repair r join @Substitute s on r.GenProcIDOrigin = s.GenProcIDNew where Not exists (select top 1 1 from @Repair54 r2 where r2.object = r.object and r2.subobject = r.subobject and r2.GenProcIDOrigin = s.GenProcIDOrigin ) group by r.object, r.subobject, s.GenProcIDOrigin55 ) as x option (maxdop 1) end if @DebugSwitch > 0 begin print ' nach Substitute-Anwendung' end update @Repair set GenProcIDNew = '' , GenProcIDOrigin56 = s.GenProcIDOrigin from @Repair r join @Substitute s on r.GenProcIDOrigin = s.GenProcIDNew option (maxdop 1) if @DebugSwitch > 0 begin print ' nach Update-Anwendung'57 end if @CountParameter = 0 begin if exists (select top 1 1 from @Repair group by GenProcIDorigin having count(*) > 1 ) begin delete @Repair from 58@Repair qr, (select min(uid_dialogdbqueue) as uid_dialogdbqueue ,GenProcIDOrigin from @Repair group by GenProcIDorigin having count(*) > 1 ) as x where59 qr.GenProcIDorigin = x.GenProcIDorigin and qr.uid_dialogdbqueue <> x.uid_dialogdbqueue end end if @CountParameter = 1 begin if exists (select top 1 601 from @Repair group by object, GenProcIDorigin having count(*) > 1 ) begin delete @Repair from @Repair qr , (select min(uid_dialogdbqueue) as uid_dialogdbqueue61 , object, GenProcIDOrigin from @Repair group by object, GenProcIDorigin having count(*) > 1 ) as x where qr.Object = x.object and qr.GenProcIDOrigin =62 x.GenProcIDorigin and qr.uid_dialogdbqueue <> x.uid_dialogdbqueue end end if @CountParameter = 2 begin if exists (select top 1 1 from @Repair group 63by object, subobject, GenProcIDorigin having count(*) > 1 ) begin delete @Repair from @Repair qr , (select min(uid_dialogdbqueue) as uid_dialogdbqueue64 , object, subobject, GenProcIDOrigin from @Repair group by object, subobject, GenProcIDorigin having count(*) > 1 ) as x where qr.object = x.object and65 qr.subobject = x.subobject and qr.GenProcIDorigin = x.GenProcIDorigin and qr.uid_dialogdbqueue <> x.uid_dialogdbqueue end end if @CountParameter 66= 0 begin delete @Repair from @Repair qr, (select min(uid_dialogdbqueue) as uid_dialogdbqueue , count(*) as CountItems from @Repair ) as x where x.CountItems67 > @compresslimit and qr.uid_dialogdbqueue <> x.uid_dialogdbqueue end if @CountParameter = 1 begin delete @Repair from @Repair qr, (select min(uid_dialogdbqueue68) as uid_dialogdbqueue , object from @Repair group by object having count(*) > @compresslimit ) as x where qr.object = x.object and qr.uid_dialogdbqueue69 <> x.uid_dialogdbqueue end if @CountParameter = 2 begin delete @Repair from @Repair qr, (select min(uid_dialogdbqueue) as uid_dialogdbqueue , object,70 subobject from @Repair group by object, subobject having count(*) > @compresslimit ) as x where qr.object = x.object and qr.subobject = x.subobject and71 qr.uid_dialogdbqueue <> x.uid_dialogdbqueue end update @Repair set Xtouched = '' if @CountParameter = 0 begin if 1 = ( select count(*) from @Repair72 ) begin update @Repair set XTouched = 'D' insert into QBMDBQueueCurrent(UID_DialogDBQueue , UID_Parameter, uid_SubParameter , GenProcID, SlotNumber, UID_Task73, Generation, StartedAt) select newid(), '', '' , case when isnull(r.GenProcIDOrigin,'') = '' then @GenProcIDFallBack else r.GenProcIDOrigin end , @SlotNumber74, @UID_Task, r.Generation, GETUTCDATE() from @Repair r where xtouched = 'D' option (maxdop 1) end end if @CountParameter = 1 begin update @Repair set XTouched75 = 'D' where UID_DialogDBQueue in (select min(r.UID_DialogDBQueue) as UID_DialogDBQueue from @Repair r group by r.object having count(*) = 1 ) option (maxdop76 1) insert into QBMDBQueueCurrent(UID_DialogDBQueue , UID_Parameter, uid_SubParameter , GenProcID, SlotNumber, UID_Task, Generation, StartedAt) select 77newid(), r.object, '' , case when isnull(r.GenProcIDOrigin,'') = '' then @GenProcIDFallBack else r.GenProcIDOrigin end , @SlotNumber, @UID_Task, r.Generation78, GETUTCDATE() from @Repair r where xtouched = 'D' option (maxdop 1) end if @CountParameter = 2 begin update @Repair set XTouched = 'D' where UID_DialogDBQueue79 in (select min(r.UID_DialogDBQueue) as UID_DialogDBQueue from @Repair r group by r.object, r.subobject having count(*) = 1 ) option (maxdop 1) insert 80into QBMDBQueueCurrent(UID_DialogDBQueue , UID_Parameter, uid_SubParameter , GenProcID, SlotNumber, UID_Task, Generation, StartedAt ) select newid(), r.object81, r.SubObject , case when isnull(r.GenProcIDOrigin,'') = '' then @GenProcIDFallBack else r.GenProcIDOrigin end , @SlotNumber, @UID_Task, r.Generation, 82GETUTCDATE() from @Repair r where xtouched = 'D' option (maxdop 1) end delete @Repair where xtouched = 'D' if @countParameter = 0 begin insert into83 @ElementBuffer (UID1, UID2, int1) select '' as object, '' as SubObject, count(*) as CountItems from @Repair where xtouched = '' select @ElementCount =84 @@ROWCOUNT end if @countParameter = 1 begin insert into @ElementBuffer (UID1, UID2, int1) select object, '' as SubObject, count(*) as CountItems from 85@Repair where xtouched = '' group by object select @ElementCount = @@ROWCOUNT end if @countParameter = 2 begin insert into @ElementBuffer (UID1, UID2, 86int1) select object, SubObject, count(*) as CountItems from @Repair where xtouched = '' group by object, SubObject select @ElementCount = @@ROWCOUNT end87 select @ElementIndex = 1 while @ElementIndex <= @ElementCount begin select top 1 @object = bu.UID1 , @Subobject = bu.UID2 , @AnzahlInGruppe = bu.Int1 88from @ElementBuffer bu where bu.ElementIndex = @ElementIndex if @DebugSwitch > 0 begin print ' im Zyklus @Repair' + @object + @Subobject + str( @AnzahlInGruppe89) end select @GenProcIDNew = null if @CountParameter = 0 begin select top 1 @GenProcIDNew = s.GenProcIDNew from @Substitute s left outer join @Repair90 q on s.GenProcIDOrigin = q.GenProcIDOrigin where s.CountOrigin = @AnzahlInGruppe end if @CountParameter = 1 begin select top 1 @GenProcIDNew = s.GenProcIDNew91 from @Substitute s left outer join @Repair q on s.GenProcIDOrigin = q.GenProcIDOrigin where s.CountOrigin = @AnzahlInGruppe and q.object = @Object group92 by s.GenProcIDNew having count(distinct isnull(q.object, '#')) = 1 end if @CountParameter = 2 begin select top 1 @GenProcIDNew = s.GenProcIDNew from93 @Substitute s left outer join @Repair q on s.GenProcIDOrigin = q.GenProcIDOrigin where s.CountOrigin = @AnzahlInGruppe and q.object = @Object and q.Subobject94 = @SubObject group by s.GenProcIDNew having count(distinct isnull(q.object, '#') + isnull(q.Subobject, '#')) = 1 end if @GenProcIDNew is null begin 95select @GenProcIDNew = newid() exec QBM_PProcessCreate @GenProcIDNew, 'DBScheduler', @DisplayName = 'DialogProcessSubstitute' insert into DialogProcessSubstitute96 (GenProcIDNew, GenProcIDOrigin, ReadyForDeleteOrExport) select distinct @GenProcIDNew, GenProcIDOrigin, 0 from @Repair where object = @object and subobject97 = @Subobject and isnull(XTouched, '') <> 'D' insert into @Substitute (GenProcIDNew, GenProcIDOrigin, CountOrigin) select distinct @GenProcIDNew, GenProcIDOrigin98, @AnzahlInGruppe from @Repair where object = @object and subobject = @Subobject and isnull(XTouched, '') <> 'D' if @DebugSwitch > 0 begin print 'neue @GenProcIDNew vergeben'99 end end if @CountParameter = 0 begin update @Repair set GenProcIDNew = @GenProcIDNew where isnull(GenProcIDNew,'') <> @GenProcIDNew end if @CountParameter100 = 1 begin update @Repair set GenProcIDNew = @GenProcIDNew where object = @object and isnull(GenProcIDNew,'') <> @GenProcIDNew end if @CountParameter =101 2 begin update @Repair set GenProcIDNew = @GenProcIDNew where object = @object and subobject = @Subobject and isnull(GenProcIDNew,'') <> @GenProcIDNew102 end select @ElementIndex += 1 end if @DebugSwitch > 0 begin print 'durchgerechnet' end if @countParameter = 0 begin insert into QBMDBQueueCurrent103(UID_DialogDBQueue , UID_Parameter, uid_SubParameter , GenProcID , SlotNumber, UID_Task, Generation, StartedAt) select newid(), '', '' , case when isnull104(x.GenProcIDNew,'') = '' then @GenProcIDFallBack else x.GenProcIDNew end , @SlotNumber, @UID_Task, x.Generation, GETUTCDATE() from (select r.GenProcIDNew105, MAX(r.Generation) as Generation from @Repair r group by GenProcIDNew ) as x option (maxdop 1) end if @countParameter = 1 begin insert into QBMDBQueueCurrent106 (UID_DialogDBQueue , UID_Parameter, uid_SubParameter , GenProcID , SlotNumber, UID_Task, Generation, StartedAt) select newid(), x.object, '' , case when107 isnull(x.GenProcIDNew,'') = '' then @GenProcIDFallBack else x.GenProcIDNew end , @SlotNumber, @UID_Task, x.Generation, GETUTCDATE() from (select object108, GenProcIDNew, MAX(r.Generation) as Generation from @Repair r group by object, GenProcIDNew ) as x option (maxdop 1) end if @countParameter = 2 begin109 insert into QBMDBQueueCurrent(UID_DialogDBQueue , UID_Parameter, uid_SubParameter , GenProcID , SlotNumber, UID_Task, Generation, StartedAt) select newid110(), x.object, x.subobject , case when isnull(x.GenProcIDNew,'') = '' then @GenProcIDFallBack else x.GenProcIDNew end , @SlotNumber, @UID_Task, x.Generation111, GETUTCDATE() from (select object, subobject , GenProcIDNew, max(r.Generation) as Generation from @Repair r group by object, subobject, GenProcIDNew 112) as x option (maxdop 1) end END TRY BEGIN CATCH exec QBM_PSessionErrorAdd default RAISERROR ('', 18, 1) WITH NOWAIT END CATCH if @DebugSwitch > 0 begin113 print 'replacer kurz vor Ende, Trancount ' + str(@@trancount) end ende: if @DebugSwitch > 0 begin print 'ReplGenProcID Ende :' + nchar(9) + convert(nvarchar114(64), GETUTCDATE(), 121) end return end 115