clean.sql 922 B

123456789101112131415161718192021222324252627282930313233
  1. CREATE PROCEDURE tsdropall3();
  2. define drop_wt integer;
  3. define drop_vt integer;
  4. let drop_wt = 0;
  5. let drop_vt = 0;
  6. select count(*) into drop_wt from systables
  7. where
  8. tabname not in ('tscontainerwindowtable') and
  9. tabid in (select tabid from syscolumns
  10. where extended_id in (select extended_id from sysxtdtypes
  11. where type = ( select type from sysxtdtypes
  12. where name = 'timeseries')
  13. )
  14. );
  15. select count(*) into drop_vt from systables
  16. where
  17. tabname not in ('tscontainerusageactivewindowvti','tscontainerusagedormantwindowvti') and
  18. am_id in (select am_id from sysams where am_name = 'ts_vtam');
  19. if (drop_wt = 0 and drop_vt = 0) then
  20. drop table TSContainerUsageActiveWindowVTI;
  21. drop table TSContainerUsageDormantWindowVTI;
  22. drop table tscontainerwindowtable;
  23. end if;
  24. END PROCEDURE;
  25. EXECUTE PROCEDURE tsdropall3();
  26. DROP PROCEDURE tsdropall3();