Go to content Go to navigation and search

Home

Current Oracle Spatial Blog Articles


Search

Browse

RSS / Atom

Email me

textpattern

Creative Commons License
All Blog Articles, Data Models and Free Source Code by Simon Greener, The SpatialDB Advisor is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.

Changing all DIMINFO sdo_tolerance values for all metadata records in one go.

Thursday May 23 2013 at 17:30

Keywordsuser_sdo_geom_metadata sdo_tolerance change all
Summary

This article shows how a simple piece of anonymous pl/sql can be used to change all sdo_tolerance values in user_sdo_geom_metadata diminfo structures in one task.

Someone contacted me about having to change all the tolerances in their user_sdo_geom_metadata due to a need to change each sdo_tolerance value from 0.005 (1cm) to 0.0005 (1mm) meters.

  1. SET serveroutput ON SIZE unlimited
  2. DECLARE
  3.    cursor meta IS
  4.     SELECT TABLE_NAME, column_name, diminfo
  5.       FROM user_sdo_geom_metadata
  6.        FOR UPDATE OF diminfo;
  7. BEGIN
  8.   FOR rec IN meta loop
  9.     IF (rec.diminfo IS NOT NULL AND rec.diminfo.COUNT >= 2) THEN
  10.        dbms_output.put_line(rec.TABLE_NAME || '.' || rec.column_name ||
  11.                             ' diminfo tolerances are ' ||
  12.                             ' X=' || rec.diminfo(1).sdo_tolerance ||
  13.                             ' Y=' || rec.diminfo(2).sdo_tolerance);
  14.        rec.diminfo(1).sdo_tolerance := rec.diminfo(1).sdo_tolerance; -- 0.05;
  15.        rec.diminfo(2).sdo_tolerance := rec.diminfo(2).sdo_tolerance; -- 0.05;
  16.        UPDATE user_sdo_geom_metadata
  17.           SET diminfo = rec.diminfo
  18.         WHERE CURRENT OF meta;
  19.     END IF;
  20.   END loop;
  21.   commit;
  22. END;
  23. /

I hope this helps someone out there…

Creative Commons License

post this at del.icio.uspost this at Diggpost this at Technoratipost this at Redditpost this at Farkpost this at Yahoo! my webpost this at Windows Livepost this at Google Bookmarkspost this to Twitter

Comment

Article Navigation:   Previous