<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Data type for auto-incrementing OBJECTID in Postgres? in ArcGIS Enterprise Questions</title>
    <link>https://community.esri.com/t5/arcgis-enterprise-questions/data-type-for-auto-incrementing-objectid-in/m-p/482030#M18651</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Using 10.2 Arcmap/ArcGIS Server on Windows I've successfully published some map services from my Postgres/PostGIS data and now I want to enable editing the features through a JavaScript web app.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So, following the JS API examples I am enabling both the geometry service and the Feature Access service with all the Operations and Capabilities enabled. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In short I'm using the serial data type for the OBJECTID primary key (tried in upper with "OBJECTID" in the DDL too) which appears to be a shortcut for creating an integer, auto-incrementing key as follows:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;CREATE TABLE test_schema.volmonwgs84e
(
&amp;nbsp; objectid serial NOT NULL,
&amp;nbsp; volmon24_i integer,
&amp;nbsp; site_id integer,
&amp;nbsp; waterbody character varying(30),
&amp;nbsp; geom geometry(MultiPoint,4326),
&amp;nbsp; CONSTRAINT volmonwgs84e_pkey PRIMARY KEY (objectid)
)
WITH (
&amp;nbsp; OIDS=FALSE
);
ALTER TABLE test_schema.volmonwgs84e
&amp;nbsp; OWNER TO postgres;

-- Index: test_schema.volmonwgs84e_geom_gist

-- DROP INDEX test_schema.volmonwgs84e_geom_gist;

CREATE INDEX volmonwgs84e_geom_gist
&amp;nbsp; ON test_schema.volmonwgs84e
&amp;nbsp; USING gist
&amp;nbsp; (geom);
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;However, when I go to publish the service (from ArcMap) the Analyzer shows the following error:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;"00166: Layer's ObjectID is not maintained by the database and the feature service is being published with Create capability enabled"
&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;Right-clicking the error kindly offers to "Add an auto-incrementing ID" for me, to which it later responds with the following. AFAIK, I ALREADY have an auto-incrementing field anyhow.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;"Executing: AddIncrementingIDField testing.test_schema.volmonwgs84e BOO
Start Time: Tue Dec 10 15:55:06 2013
ERROR 000152: You cannot add an incrementing ID field to a table registered with the geodatabase.
Failed to execute (AddIncrementingIDField).
Failed at Tue Dec 10 15:55:07 2013 (Elapsed Time: 0.70 seconds)&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So, what data type and rules need to be on this auto-incrementing field, and what is AddIncrementingIDField trying to do for me?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;UPDATE:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thinking that my issue was the "new" PostGIS/Postgres approaches to things I've also tried creating a table with these older approach as follows:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;1. manually setting the sequence on integer PK column instead of using the SERIAL type, &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;2. using "SELECT AddGeometryColumn" to create the geometry column, and therein using the old constraints approach with the final argument = false (&lt;/SPAN&gt;&lt;A href="http://postgis.refractions.net/docs/AddGeometryColumn.html" rel="nofollow noopener noreferrer" target="_blank"&gt;http://postgis.refractions.net/docs/AddGeometryColumn.html&lt;/A&gt;&lt;SPAN&gt;) &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
CREATE SEQUENCE test_schema.mypoint_const_b_seq
&amp;nbsp; INCREMENT 1
&amp;nbsp; MINVALUE 1
&amp;nbsp; MAXVALUE 9223372036854775807
&amp;nbsp; START 1
&amp;nbsp; CACHE 1;
ALTER TABLE test_schema.mypoint_const_b_seq
&amp;nbsp; OWNER TO postgres;

CREATE TABLE test_schema.mypoint_const_b
(
&amp;nbsp; objectid integer NOT NULL DEFAULT nextval('test_schema.mypoint_const_b_seq'::regclass),
&amp;nbsp; volmon24_i integer,
&amp;nbsp; site_id integer,
&amp;nbsp; waterbody character varying(30),
&amp;nbsp; CONSTRAINT mypoint_const_b_pkey PRIMARY KEY (objectid)
)
WITH (
&amp;nbsp; OIDS=FALSE
);

SELECT AddGeometryColumn ('test_schema','mypoint_const_b','geom',4326,'MULTIPOINT',2, false);

ALTER TABLE test_schema.mypoint_const_b
&amp;nbsp; OWNER TO postgres;

CREATE INDEX mypoint_const_b_geom_gist
&amp;nbsp; ON test_schema.mypoint_const_b
&amp;nbsp; USING gist
&amp;nbsp; (geom);

&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;But I still get a fatal error when trying to create a service with Feature Access "Create" capability enabled with the same message: &lt;/SPAN&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;"00166: Layer's ObjectID is not maintained by the database and the feature service is being published with Create capability enabled"
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I know that the database IS maintaining the PK because I can add features using QGIS just fine. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;PS, buried in this excellent link (&lt;/SPAN&gt;&lt;A href="http://proceedings.esri.com/library/userconf/proc13/tech-workshops/tw_192.pdf" rel="nofollow noopener noreferrer" target="_blank"&gt;http://proceedings.esri.com/library/userconf/proc13/tech-workshops/tw_192.pdf&lt;/A&gt;&lt;SPAN&gt;)&amp;nbsp; I see that Arc doesn't like fields with quotes (which is how you force CAPS on OBJECTID. Lowercase objectid appears to be just fine to ArcMap at least.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 21:16:28 GMT</pubDate>
    <dc:creator>JohnZastrow</dc:creator>
    <dc:date>2021-12-11T21:16:28Z</dc:date>
    <item>
      <title>Data type for auto-incrementing OBJECTID in Postgres?</title>
      <link>https://community.esri.com/t5/arcgis-enterprise-questions/data-type-for-auto-incrementing-objectid-in/m-p/482030#M18651</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Using 10.2 Arcmap/ArcGIS Server on Windows I've successfully published some map services from my Postgres/PostGIS data and now I want to enable editing the features through a JavaScript web app.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So, following the JS API examples I am enabling both the geometry service and the Feature Access service with all the Operations and Capabilities enabled. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In short I'm using the serial data type for the OBJECTID primary key (tried in upper with "OBJECTID" in the DDL too) which appears to be a shortcut for creating an integer, auto-incrementing key as follows:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;CREATE TABLE test_schema.volmonwgs84e
(
&amp;nbsp; objectid serial NOT NULL,
&amp;nbsp; volmon24_i integer,
&amp;nbsp; site_id integer,
&amp;nbsp; waterbody character varying(30),
&amp;nbsp; geom geometry(MultiPoint,4326),
&amp;nbsp; CONSTRAINT volmonwgs84e_pkey PRIMARY KEY (objectid)
)
WITH (
&amp;nbsp; OIDS=FALSE
);
ALTER TABLE test_schema.volmonwgs84e
&amp;nbsp; OWNER TO postgres;

-- Index: test_schema.volmonwgs84e_geom_gist

-- DROP INDEX test_schema.volmonwgs84e_geom_gist;

CREATE INDEX volmonwgs84e_geom_gist
&amp;nbsp; ON test_schema.volmonwgs84e
&amp;nbsp; USING gist
&amp;nbsp; (geom);
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;However, when I go to publish the service (from ArcMap) the Analyzer shows the following error:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;"00166: Layer's ObjectID is not maintained by the database and the feature service is being published with Create capability enabled"
&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;Right-clicking the error kindly offers to "Add an auto-incrementing ID" for me, to which it later responds with the following. AFAIK, I ALREADY have an auto-incrementing field anyhow.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;"Executing: AddIncrementingIDField testing.test_schema.volmonwgs84e BOO
Start Time: Tue Dec 10 15:55:06 2013
ERROR 000152: You cannot add an incrementing ID field to a table registered with the geodatabase.
Failed to execute (AddIncrementingIDField).
Failed at Tue Dec 10 15:55:07 2013 (Elapsed Time: 0.70 seconds)&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So, what data type and rules need to be on this auto-incrementing field, and what is AddIncrementingIDField trying to do for me?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;UPDATE:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thinking that my issue was the "new" PostGIS/Postgres approaches to things I've also tried creating a table with these older approach as follows:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;1. manually setting the sequence on integer PK column instead of using the SERIAL type, &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;2. using "SELECT AddGeometryColumn" to create the geometry column, and therein using the old constraints approach with the final argument = false (&lt;/SPAN&gt;&lt;A href="http://postgis.refractions.net/docs/AddGeometryColumn.html" rel="nofollow noopener noreferrer" target="_blank"&gt;http://postgis.refractions.net/docs/AddGeometryColumn.html&lt;/A&gt;&lt;SPAN&gt;) &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
CREATE SEQUENCE test_schema.mypoint_const_b_seq
&amp;nbsp; INCREMENT 1
&amp;nbsp; MINVALUE 1
&amp;nbsp; MAXVALUE 9223372036854775807
&amp;nbsp; START 1
&amp;nbsp; CACHE 1;
ALTER TABLE test_schema.mypoint_const_b_seq
&amp;nbsp; OWNER TO postgres;

CREATE TABLE test_schema.mypoint_const_b
(
&amp;nbsp; objectid integer NOT NULL DEFAULT nextval('test_schema.mypoint_const_b_seq'::regclass),
&amp;nbsp; volmon24_i integer,
&amp;nbsp; site_id integer,
&amp;nbsp; waterbody character varying(30),
&amp;nbsp; CONSTRAINT mypoint_const_b_pkey PRIMARY KEY (objectid)
)
WITH (
&amp;nbsp; OIDS=FALSE
);

SELECT AddGeometryColumn ('test_schema','mypoint_const_b','geom',4326,'MULTIPOINT',2, false);

ALTER TABLE test_schema.mypoint_const_b
&amp;nbsp; OWNER TO postgres;

CREATE INDEX mypoint_const_b_geom_gist
&amp;nbsp; ON test_schema.mypoint_const_b
&amp;nbsp; USING gist
&amp;nbsp; (geom);

&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;But I still get a fatal error when trying to create a service with Feature Access "Create" capability enabled with the same message: &lt;/SPAN&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;"00166: Layer's ObjectID is not maintained by the database and the feature service is being published with Create capability enabled"
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I know that the database IS maintaining the PK because I can add features using QGIS just fine. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;PS, buried in this excellent link (&lt;/SPAN&gt;&lt;A href="http://proceedings.esri.com/library/userconf/proc13/tech-workshops/tw_192.pdf" rel="nofollow noopener noreferrer" target="_blank"&gt;http://proceedings.esri.com/library/userconf/proc13/tech-workshops/tw_192.pdf&lt;/A&gt;&lt;SPAN&gt;)&amp;nbsp; I see that Arc doesn't like fields with quotes (which is how you force CAPS on OBJECTID. Lowercase objectid appears to be just fine to ArcMap at least.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 21:16:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-enterprise-questions/data-type-for-auto-incrementing-objectid-in/m-p/482030#M18651</guid>
      <dc:creator>JohnZastrow</dc:creator>
      <dc:date>2021-12-11T21:16:28Z</dc:date>
    </item>
    <item>
      <title>Re: Data type for auto-incrementing OBJECTID in Postgres?</title>
      <link>https://community.esri.com/t5/arcgis-enterprise-questions/data-type-for-auto-incrementing-objectid-in/m-p/482031#M18652</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I have run into similar roadblocks with my own workflow.&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I assumed you were using a Query Layer in your map service, but I am confused by the two seemingly contradictory error messages:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code jive_text_macro"&gt;00166: Layer's ObjectID is not maintained by the database and the feature service is being published with Create capability enabled&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;vs&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code jive_text_macro"&gt;ERROR 000152: You cannot add an incrementing ID field to a table registered with the geodatabase&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So it sounds like your table is registered with the geodatabase, but does not have a geodatabase-maintained OBJECTID field and instead maintains an auto-incrementing field, which is strange to me.&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In my experience (using ArcPy), geodatabase registration (unfortunately) results in the auto-increment constraint being removed from the OBJECTID column, as ESRI wants you to instead call the sde.next_rowid(schema, table) function when inserting new records via SQL.&amp;nbsp; In this case, you shouldn't have to worry about calling the AddIncrementingIDField function, as the OBJECTID field should suffice.&amp;nbsp; But how were you able to register the table with the geodatabase without having your autoincrement constraint removed?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Were you able to find a workaround?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 19 May 2014 19:40:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-enterprise-questions/data-type-for-auto-incrementing-objectid-in/m-p/482031#M18652</guid>
      <dc:creator>JasonGreenlaw</dc:creator>
      <dc:date>2014-05-19T19:40:08Z</dc:date>
    </item>
  </channel>
</rss>

