darold / ora2pg

Ora2Pg is a free tool used to migrate an Oracle database to a PostgreSQL compatible schema. It connects your Oracle database, scan it automatically and extracts its structure or data, it then generates SQL scripts that you can load into PostgreSQL.
http://www.ora2pg.com/
GNU General Public License v3.0
1.01k stars 342 forks source link

Data Mismatch for geometry column from Oracle to postgres #1337

Closed mukesh3388 closed 2 years ago

mukesh3388 commented 2 years ago

Hi Team,

We are extracting the data from Oracle for Geometry column from Ora2Pg tool and when we are importing the data into the postgres , its is completely different from Oracle, we tried both the insert and Copy command. Please help, below is the example.

Below is the Oracle create Table script -; _CREATE TABLE UNIT_PROPERTY ("GEOMETRY" "MDSYS"."SDOGEOMETRY") Below is the Postgres Create Table Script from ORa2Pg Tool -: _CREATE TABLE unitproperty (geometry geometry(POLYGONZ,4326) ; Below is the Insert Statement from ora2pg Tool -: INSERT INTO unit_property (geometry) VALUES (ST_GeomFromText('POLYGONZ ((-87.8562677 37.4892555 0.0, -87.8550168 37.4884629 0.0, -87.8541208 37.487885 0.0, -87.8531547 37.4872743 0.0, -87.8528804 37.487213 0.0, -87.8523138 37.4872451 0.0, -87.8518654 37.4872792 0.0, -87.8515047 37.4873659 0.0, -87.8512015 37.4874753 0.0, -87.8508466 37.4876516 0.0, -87.8504561 37.4878009 0.0, -87.8502505 37.4878739 0.0, -87.8500223 37.4879015 0.0, -87.8498417 37.4879839 0.0, -87.8496687 37.4881358 0.0, -87.8495365 37.4883809 0.0, -87.8494141 37.4885961 0.0, -87.8491102 37.4889812 0.0, -87.8489472 37.4891953 0.0, -87.8483968 37.4900309 0.0, -87.8502369 37.4922706 0.0, -87.8505341 37.4924736 0.0, -87.8509166 37.4926391 0.0, -87.8511293 37.4927186 0.0, -87.8562677 37.4892555 0.0))', 8307),'2005-01-27 09:51:23','2007-11-27 19:57:05')

So first I have change the Column Geometry (geometry geometry(POLYGONZ,4326) to (geometry geometry(POLYGONZ,8307) ;

After Table creation in Postgres and data is inserted sucsessfully into the postgres database.

But when i am selecting that particular data it is shwoing like below.

"01030000A0732000000100000019000000C1070A17CDF655C0AEF199EC9FBE42400000000000000000F5616298B8F655C09867CAF385BE4240000000000000000056B549EAA9F655C0BF9A030473BE4240000000000000000070BB2B169AF655C0355717015FBE424000000000000000009059AC9795F655C0D097DEFE5CBE424000000000000000007D3B2E4F8CF655C071D1240C5EBE42400000000000000000036674F684F655C0B202322A5FBE42400000000000000000FBB8910D7FF655C0C2D77C0162BE424000000000000000009833DB157AF655C0CC8D339765BE424000000000000000006B3A4C4574F655C0C9EB1C5E6BBE42400000000000000000C20B6CDF6DF655C0CD3A884270BE4240000000000000000017BA12816AF655C03689E6A672BE42400000000000000000BAD7EEC366F655C0AD156D8E73BE42400000000000000000BB1171CE63F655C0BEBCA54176BE42400000000000000000D4BBD3F860F655C0DF80E03B7BBE42400000000000000000881057CE5EF655C0DBBEEC4383BE42400000000000000000B910F5CC5CF655C0013A27518ABE42400000000000000000CDEC4ED257F655C0EE2D9BEF96BE42400000000000000000F801A32655F655C0AF6D9BF39DBE42400000000000000000FD8117224CF655C0C5C32055B9BE424000000000000000008ED607486AF655C022E417B902BF4240000000000000000080E893266FF655C05A12FB5F09BF42400000000000000000E827E66A75F655C08D9D4BCC0EBF42400000000000000000B60A07E778F655C0C290306711BF42400000000000000000C1070A17CDF655C0AEF199EC9FBE42400000000000000000"

So i just want to know whether the data is correct from the Postgrs Database as it is not showing in the same way as it is showing in Oracle like , Cordinates.

Please help here

darold commented 2 years ago

Hi,

First, when there is no SRID information, Ora2Pg use 4326 by default. You can change this using the DEFAULT_SRID in ora2pg.conf.

What SQL query are you using to retrieve the data above? It look to be a simple SELECT geometry FROM unit_property; by default the output is the binary form or the geometry, if you want the text output use the following:

SELECT ST_AsText(geometry) FROM unit_property;

So this is not an Ora2Pg issue but related to a PostgreSQL+PostGis use but if the geometry is not correctly exported that could be.

mukesh3388 commented 2 years ago

Thanks darold for the information.

Can you confirm me please which SRID i have to use in postgres and from where i can check the SRID in oracle or equivalent.

Thanks Mukesh Kumar

darold commented 2 years ago

Sorry for responding so late, I guess that since this time you have found the way to get the default SRID used in Oracle. Closing.