Skip to main content
Question

Create Unique ObjectId in Oracle out of different shapes, daily.


mvloenhout
Participant
Forum|alt.badge.img

Hello,

I have a problem to generate a unique ObjectId in Oracle. This is a Number.

I want to copy data from a shape to Oracle. No problem for the data, but Oracle requires a Unique ObjectId. I can generate this once with a Counter, but I want to run the workbench daily with different shapes. So if I use the counter and let it start at 10, the next day it will also start with 10 and then Oracle doesn't accept te data because the ObjectId isn't unique.

How can I let FME generate a Unique ObjectID each transformation?

Thank you, Marlies

10 replies

ebygomm
Influencer
Forum|alt.badge.img+31
  • Influencer
  • June 6, 2016

You could use an sqlcreator to get the max ObjectID in the existing table and then add this figure to the count attribute to gain the ObjectID


nielsgerrits
VIP

This works for me in PostGIS.


david_r
Evangelist
  • June 6, 2016
nielsgerrits wrote:

This works for me in PostGIS.

Unfortunately, Oracle does not support the implicit creation of sequences, like PostgreSQL does. Something like it (IDENTITY column) was introduced in Oracle 12c, but as far as I know that syntax it isn't supported by FME.


mvloenhout
Participant
Forum|alt.badge.img
  • Author
  • Participant
  • June 6, 2016
ebygomm wrote:

You could use an sqlcreator to get the max ObjectID in the existing table and then add this figure to the count attribute to gain the ObjectID

Thank you for your fast reaction. Do you have written this down once?

My SQl is not very good. So if you have an example, I can adapt this to my case.


mvloenhout
Participant
Forum|alt.badge.img
  • Author
  • Participant
  • June 6, 2016
nielsgerrits wrote:

This works for me in PostGIS.

I've tried, but for Oracle the above will not work. I'm going to try the SQL-script.

Thank you!


gio
Contributor
Forum|alt.badge.img+15
  • Contributor
  • June 6, 2016

select Max(ObjectID) as LastId from etc.

Then use counter and set start from = LastID


ebygomm
Influencer
Forum|alt.badge.img+31
  • Influencer
  • June 6, 2016
mvloenhout wrote:

Thank you for your fast reaction. Do you have written this down once?

My SQl is not very good. So if you have an example, I can adapt this to my case.

Within an sqlcreator something like the following

select max(ObjectID) as maxObjectID from table1

This will return a single record with an attribute called maxObjectID which you can use.

You could then join this with your other records and using an attributecreator set ObjectID to equal count + maxObjectID for example


mvloenhout
Participant
Forum|alt.badge.img
  • Author
  • Participant
  • June 6, 2016

It works. Thank you


david_r
Evangelist
  • June 6, 2016
ebygomm wrote:

Within an sqlcreator something like the following

select max(ObjectID) as maxObjectID from table1

This will return a single record with an attribute called maxObjectID which you can use.

You could then join this with your other records and using an attributecreator set ObjectID to equal count + maxObjectID for example

Just a small detail: Since Oracle is upper case by default, the attribute you need to expose will be called MAXOBJECTID


ebygomm
Influencer
Forum|alt.badge.img+31
  • Influencer
  • June 6, 2016
david_r wrote:

Just a small detail: Since Oracle is upper case by default, the attribute you need to expose will be called MAXOBJECTID

But if you expose attributes using "populate from SQL query" FME will helpfully sort this out for you, and also confirm you've got your sql right. :-)


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings