Wednesday, September 29, 2010

Best Way To Remove Fat From Sausage

APEX and the question: Where have remained my metadata?

Anyone who has ever created a small or large APEX Geo-application, described in the following situation may have experienced before. Each table with an SDO_GEOMETRY column requires a registration in the SDO metadata of the Oracle database. This is an insert in the user-oriented view USER_SDO_GEOM_METADATA and can look like this:

SQL> insert into USER_SDO_GEOM_METADATA (
table_name, column_name
,
diminfo,
 srid) 
values (
'GEOTAB'
'geometry',
sdo_dim_array (sdo_dim_element ('X', -180,180,0.005)
sdo_dim_element ('Y', -90,90,0.005)),
8307 );

Expanding an application in APEX and used for registering the SDO_GEOMETRY column in the metadata of the SQL Workshop and then as far as running without problems.


A short

SQL> select * from USER_SDO_GEOM_METADATA where table_name = 'GEOTAB';

returns no results.

 What happened? Where the entry remains in the metadata? 
With DBA rights, it is easy to search in the table of the user MDSYS.

SQL> select * from mdsys.sdo_geom_metadata_table;

There is in the column SDO_OWNER then find instead of the expected user (in this example SPATIAL) according to the Web listener used by APEX to either ANONYMOUS, APEX_PUBLIC_USER or HTMLDB_PUBLIC_USER. This is the username of the APEX session, then in the scheme also SDO_GEOMETRY the metadata is registered.
How can this be cleaned up now?
 Ask your DBA to your users UPDATE privileges for the table MDSYS SDO_GEOM_METADATA_TABLE blame. 

SQL> grant update on mdsys.sdo_geom_metadata_table;

SDO_OWNER Then change the entry as follows:

 
SQL> update MDSYS.SDO_GEOM_METADATA_TABLE
set sdo_owner = 'SPATIAL'
where sdo_table_name = ' GEOTAB 'and sdo_owner =' ANONYMOUS ';
 if you check the metadata should now all be alright. 

0 comments:

Post a Comment