# Insert geometry from a projection transformation on materialized view

Is there a way to build geometry into a materialized view that is transformed prior to insert?

So as an example say I have the following case:

CASE
WHEN
t1.latitude is not null
and
t1.longitude is not null
THEN MDSYS.SDO_GEOMETRY(2001,40000, NULL,
MDSYS.SDO_ELEM_INFO_ARRAY(1,1,1),
MDSYS.SDO_ORDINATE_ARRAY(t1.longitude,t1.latitude))

But need to somehow incorporate this in the view definition:

MDSYS.SDO_CS.TRANSFORM(SDO_GEOMETRY(2001,4326,MDSYS.SDO_POINT_TYPE(t1.longitude, t1.latitude, NULL), NULL,NULL),40000))

Thanks

###### Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

PartnerCommented:
Not sure I understand the question but... you should be able to define a view that includes the function calls to the various mdsys functions you mention and then simply create your materialized view a select * from your view. Something like this:
``````CREATE VIEW my_view AS
SELECT
CASE
WHEN
t1.latitude is not null
and
t1.longitude is not null
THEN MDSYS.SDO_GEOMETRY(2001,40000, NULL,
MDSYS.SDO_ELEM_INFO_ARRAY(1,1,1),
MDSYS.SDO_ORDINATE_ARRAY(t1.longitude,t1.latitude)) AS my_field
FROM
some_table
;

CREATE my_mv AS SELECT * FROM my_view;
``````
0
Author Commented:
Right, but is there a way to transform the geometry on insert?
I need to take lat long goemetry and transform to my custom projection using this:
MDSYS.SDO_CS.TRANSFORM(SDO_GEOMETRY(2001,4326,MDSYS.SDO_POINT_TYPE(t1.longitude, t1.latitude, NULL), NULL,NULL),40000))
0
PartnerCommented:
You can just use that function call in your view definition instead
0
Author Commented:
Okay I played around with it a bit and do not have the proper syntax for the transform call.
Any idea what that would look like in the view definition?

It would require an iterative process of some sort I think since each geometry would be transformed based on that specific record's Long/Lat values.
0
Author Commented:
Well I avoided the Base View and stuck with the materialized view. However, I created a function to return type MDSYS.SDO_GEOMETRY

So from this case in the MV definition:
CREATE VIEW my_view AS
SELECT
CASE
WHEN
t1.latitude is not null
and
t1.longitude is not null
THEN CONVERT_GEOM(t1.longitude, t1.latitude) --my function call
else null
end   AS GEOMETRY

Then my function calls the MDSYS.SDO_CS.TRANSFORM function.
So for now that will suffice although it is slow on creation.

0

Experts Exchange Solution brought to you by

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Author Commented:
My initial intent was to insert a geometry from the sdo functions using the transform function first to get the geometry into my projection. The expert offered a solution which created excess objects (view in this case). I created a function to return the desired geometry transformed into my projection. It seemed the simpler of the two solutions.
0
###### It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Oracle Database

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.