Skip to main content
Question

Reading multiple geometry using sql executor

  • September 28, 2017
  • 13 replies
  • 81 views

f.kemminje
Contributor
Forum|alt.badge.img+11

Can I read multiple geometry using sqlexecutor. In my case , i dont have two geometry in one table. i am extracting/constructing multiple (2) geometry from different tables and the sql gives resultset with two geometries in one row.

two geometry from sql resultset not from one table

and later i will deaggregate this and use these geometries for different purposes.

how can i achieve this using fme?

This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

13 replies

david_r
Celebrity
  • 8394 replies
  • September 28, 2017

Which database are you using and how are the geometries stored?

One solution could be to cast both geometries to e.g. WKB and then use two separate GeometryReplacers to extract the geometries. Something like (pseudo-code):

select 
  as_binary(t1.geom) as geom1, 
  as_binary(t2.geom) as geom2
from 
  mytable1 t1 join mytable2 t2 on t1.id=t2.id

Then expose "geom1" and "geom2" and send them to the GeometryReplacer as OGC Well-Known Binary.


f.kemminje
Contributor
Forum|alt.badge.img+11
  • Author
  • Contributor
  • 189 replies
  • September 28, 2017

Which database are you using and how are the geometries stored?

One solution could be to cast both geometries to e.g. WKB and then use two separate GeometryReplacers to extract the geometries. Something like (pseudo-code):

select 
  as_binary(t1.geom) as geom1, 
  as_binary(t2.geom) as geom2
from 
  mytable1 t1 join mytable2 t2 on t1.id=t2.id

Then expose "geom1" and "geom2" and send them to the GeometryReplacer as OGC Well-Known Binary.

@david_r oracle sql says as_binary invalid identifier

 

 

as_binary

 


erik_jan
Contributor
Forum|alt.badge.img+22
  • Contributor
  • 2179 replies
  • September 28, 2017

Why do you need to use the SQLExecutor transformer and not an Oracle Spatial reader or the FeatureReader.

In your case the SQLExecutor seems to complicate matters only.


david_r
Celebrity
  • 8394 replies
  • September 28, 2017

For Oracle Spatial, use:

SDO_UTIL.TO_WKBGEOMETRY(geom)

Doc: https://docs.oracle.com/cd/B28359_01/appdev.111/b28400/sdo_util.htm#SPATL1250

For ArcSDE with an Oracle backend, use:

sde.st_asbinary(geom)

Doc: http://desktop.arcgis.com/en/arcmap/10.3/manage-data/using-sql-with-gdbs/st-asbinary.htm


david_r
Celebrity
  • 8394 replies
  • September 28, 2017

Why do you need to use the SQLExecutor transformer and not an Oracle Spatial reader or the FeatureReader.

In your case the SQLExecutor seems to complicate matters only.

It's pretty handy if you need to join several tables and haven't got the option of creating a view in the database.

david_r
Celebrity
  • 8394 replies
  • September 28, 2017
@david_r oracle sql says as_binary invalid identifier

 

 

as_binary

 

It's pseudo-code, you'll have to replace that with whatever your backend supports.

f.kemminje
Contributor
Forum|alt.badge.img+11
  • Author
  • Contributor
  • 189 replies
  • September 28, 2017

Why do you need to use the SQLExecutor transformer and not an Oracle Spatial reader or the FeatureReader.

In your case the SQLExecutor seems to complicate matters only.

i extractring the data by joining many tables. i use oracle spatial.

 

 

 


f.kemminje
Contributor
Forum|alt.badge.img+11
  • Author
  • Contributor
  • 189 replies
  • September 28, 2017

@david_r

my database is oracle spatial


erik_jan
Contributor
Forum|alt.badge.img+22
  • Contributor
  • 2179 replies
  • September 28, 2017

Why do you need to use the SQLExecutor transformer and not an Oracle Spatial reader or the FeatureReader.

In your case the SQLExecutor seems to complicate matters only.

OK, I can see the point.

 

But in this example I would use two SQLCreators (not SQLExecutors), each with a query containing 1 geometry.

 

No need to de-aggregate afterwards.

 

 


f.kemminje
Contributor
Forum|alt.badge.img+11
  • Author
  • Contributor
  • 189 replies
  • September 28, 2017

@david_r

Thank you David.


david_r
Celebrity
  • 8394 replies
  • September 28, 2017
OK, I can see the point.

 

But in this example I would use two SQLCreators (not SQLExecutors), each with a query containing 1 geometry.

 

No need to de-aggregate afterwards.

 

 

Not sure I follow. You mean doing the join in the workspace rather than in the database?

erik_jan
Contributor
Forum|alt.badge.img+22
  • Contributor
  • 2179 replies
  • September 28, 2017
Not sure I follow. You mean doing the join in the workspace rather than in the database?
Yes, if needed. But according to the question, two geometries are read, aggregated by the read and afterwards de-aggregated to be used separately. If used separately, why join in the first place?

 

 


david_r
Celebrity
  • 8394 replies
  • September 28, 2017
Yes, if needed. But according to the question, two geometries are read, aggregated by the read and afterwards de-aggregated to be used separately. If used separately, why join in the first place?

 

 

Ah, I see. I must admit I didn't take the "aggregate" bit literally in this context.