Skip to main content
Question

retrieve last used oid value and set counter to start with next number. Postgres 14/PostGIS oid

  • July 31, 2023
  • 1 reply
  • 42 views

gisbradokla
Enthusiast
Forum|alt.badge.img+17

I am writing to postgres/postgis st_geometry in an autmation that is loading many dwg datasets. (runs workbench on each dwg)

The postgis writer shows that ver 14 ignores writing od. 

I need to get an oid calculated beginning with the last oid used (in the previous automation)

NOTE: postgis writer specifies that oid is ignored at postgres 14.

I tried just using a counter and hoped that writing to existing would automatically write the oid. (I get an error the oid already exists).

I am using this oid as the primary key so that It doesn't have to be set when adding to esri.

I have attempted to read the flat postgres table and sample the last n and then use that as a parameter to set the start number of the counter. But have not been successful getting that to work.

imageAny ideas on how to do this?

 

1 reply

virtualcitymatt
Celebrity
Forum|alt.badge.img+35

well, if your oid's are always sequential (that is the highest number is the most recent) then you can use this call inside an SQLExcecutor to get the last row.

SELECT * FROM "<table_name>" 
ORDER BY "oid" DESC
LIMIT 1;

This should give you the last record from the table. From there you can use a counter starting from the oid value (or oid+1 ).


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