HOW TO
**This article is ArcSDE version 9.2 specific**
Warning:
The information presented in this doc is internal only and should not be distributed outside of ESRI.
1. To use this method against an Oracle database, save the following in a file named host.bat:
sqlplus sde/sde @state_delete_leaf_states.sql
tmp.bat
Code:
set feedback off
set serveroutput on
exec dbms_output.enable(1000000);
spool tmp.bat
declare
cursor leaf_states is
SELECT state_id FROM sde.states WHERE state_id NOT IN
(SELECT parent_state_id FROM sde.states)
AND state_id NOT IN (SELECT DISTINCT state_id FROM sde.versions)
ORDER BY state_id;
del_cnt number default 0;
begin
for mloop in leaf_states loop
dbms_output.put_line('sdeversion -o delete_state -S '||mloop.state_id||' -u sde -p sde -i 5151 -N');
del_cnt := 1;
end loop;
IF del_cnt = 0 THEN
dbms_output.put_line('exit');
ELSE
dbms_output.put_line('host.bat');
END IF;
end;
/
spool off
exit
Code:
-- Trim unreferenced leaf states
set nocount on
While (SELECT count(*) FROM sde.sde_states WHERE state_id NOT IN
(SELECT parent_state_id FROM sde.sde_states)
AND state_id NOT IN (SELECT DISTINCT state_id FROM sde.sde_versions)) > 0
begin
declare @str varchar(200)
declare @stateid int
declare leaf_states cursor
for
SELECT state_id FROM sde.sde_states WHERE state_id NOT IN
(SELECT parent_state_id FROM sde.sde_states)
AND state_id NOT IN (SELECT DISTINCT state_id FROM sde.sde_versions)
ORDER BY state_id
Open leaf_states
fetch leaf_states into @stateid
while (@@fetch_status=0)
begin
set @str = 'sdeversion -o delete_state -S ' + ltrim(str(@stateid)) + ' -u sde -p sde -i sde:sqlserver:sofia -D b93 -N'
print @str
exec xp_cmdshell @str
fetch leaf_states into @stateid
end
close leaf_states
Deallocate leaf_states
End
print 'No more leaf states';
Article ID:000009733
Get help from ArcGIS experts
Download the Esri Support App