使用Sql插入sde是ObjectId的处理方式

使用ArcGIS导入或新增数据时,objectid会自动自增,但通过sql时,则需要手动调用sde的函数sde.next_rowid来处理,否则可能导入objectid的重复;

  • next_rowid的定义

Next_RowID 将注册到地理数据库的表作为输入参数,并返回 ObjectID (RowID) 字段的下一个值。
使用 SQL 将一行插入到表中时,可以使用此值。
如果您指定的表未注册到地理数据库,则返回错误

1
<geodatabase administrator schema>.next_rowid (<table owner>, <table name>)

在大多数地理数据库中,地理数据库管理员方案是 sde。但是,在 SQL Server dbo 方案地理数据库中,则为 dbo;而在 Oracle 用户方案地理数据库中,则为用户方案的名称。 

  • PostgreSQL
1
2
3
4
5
INSERT INTO webman.applicants (objectid, app_name, status)
VALUES
(sde.next_rowid('webman', 'applicants'), 'Roy Bean', 'active')
 
Query returned successfully: 1 row affected, 109 ms execution time.

 

1
2
3
4
5
INSERT INTO webman.logins (id, l_name)
VALUES
(sde.next_rowid('WEBMAN', 'LOGINS'), 'maplebutter')
 
Notice: Class webman.logins not registered to the Geodatabase.
  • Oracle
1
2
3
4
5
6
7
INSERT INTO webman.applicants (objectid, app_name, status)
VALUES
(sde.gdb_util.next_rowid('WEBMAN', 'APPLICANTS'), 'Roy Bean', 'active');
 
1 row created
 
COMMIT;

 

1
2
3
4
5
6
7
8
9
INSERT INTO webman.logins (id, l_name)
VALUES
(sde.gdb_util.next_rowid('WEBMAN', 'LOGINS'), 'maplebutter');
 
 
(sde.gdb_util.next_rowid('WEBMAN', 'LOGINS'), 'maplebutter');
 *
ERROR at line 3:
ORA-20220: Class WEBMAN.LOGINS not registered to the Geodatabase.

 

 

参考地址:https://resources.arcgis.com/zh-cn/help/main/10.1/index.html#/na/006z000000w8000000/

posted @   xingtian  阅读(77)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 为DeepSeek添加本地知识库
· 精选4款基于.NET开源、功能强大的通讯调试工具
· DeepSeek智能编程
· [翻译] 为什么 Tracebit 用 C# 开发
· 腾讯ima接入deepseek-r1,借用别人脑子用用成真了~
点击右上角即可分享
微信分享提示