-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathMaintPath.xxm
36 lines (30 loc) · 1.04 KB
/
MaintPath.xxm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
[[/
########## ATTENTION ##########
Run this script selectivly (preferably not scheduled),
e.g. to rebuild ObjPath data
]][[@txDefs,DataLank,txSession,txTerms,txFilterSql,]][[!var
i,j:integer;
]][[
Context.ContentType:='text/plain';
Context.BufferSize:=0;
CheckMaintProtect(Context);
Session.DbCon.BeginTrans;
try
Context.SendHTML('Clearing...'#13#10);
Session.DbCon.Execute('DELETE FROM ObjPath',[]);
Session.DbCon.Execute('INSERT INTO ObjPath (pid,oid,lvl) SELECT id,id,0 FROM Obj',[]);
i:=Session.DbCon.Execute('INSERT INTO ObjPath (pid,oid,lvl) SELECT pid,id,1 FROM Obj WHERE pid<>0',[]);
j:=0;
while i<>0 do
begin
inc(j);
Context.SendHTML('level '+IntToStr(j)+': '+IntToStr(i)+#13#10);
i:=Session.DbCon.Execute('INSERT INTO ObjPath (pid,oid,lvl) SELECT ObjPath.pid,Obj.id,ObjPath.lvl+1 FROM ObjPath '+
'INNER JOIN Obj ON Obj.pid=ObjPath.oid WHERE ObjPath.lvl=(SELECT MAX(lvl) FROM ObjPath)',[]);
end;
Session.DbCon.CommitTrans;
except
Session.DbCon.RollbackTrans;
raise;
end;
Context.SendHTML('-- done'#13#10);