一、引言

将shp文件导入oracle中就想着直接用sql进行普通查询和空间查询,这样直接通过webserver发布就可以不用arcgis server直接进行接口调用了,感觉这样比较接触底层些,所以就开始摸索了==

前提是oracle安装好,shp数据也导入oracle里面去了。

二、空间查询sql的使用

从arcgis官网中找到帮助文档,写了一些简单的查询sql。点击打开链接

哈哈,看上去很容易吧,不过我高兴的实在太早了==

三、查询出现问题

1、问题惊现

这个官方提供的函数竟然不能使用了,尴尬==

2、查了好多资料,终于找原因

在 Oracle 中,ST_Geometry 和 ST_Raster 的 SQL 函数使用通过 Oracle 的外部过程代理(即 extproc)访问的共享库。要将 SQL 和 ST_Geometry 或 ST_Raster 配合使用或访问 GDB_ITEMS_VW 和 GDB_ITEMRELATIONSHIPS_VW 视图中的 ArcSDE XML 列,Oracle 必须能够访问这些库。因此,这些库必须存在于 Oracle 服务器上,并且必须通过 Oracle 的外部过程框架调用它们。

在 ArcGIS 中,不设置 Oracle 监听器也可以使用 ST_Geometry 和 ST_Raster。但是,您将不会拥有 ArcGIS 客户端的全部功能,也不会拥有 SQL 客户端的任何功能(如 SQL*Plus)。例如,如果未配置 Oracle 监听器,则无法对 ArcMap 的查询图层中的 ST_Geometry 列或包含 ST_Raster 列的版本化表使用 SQL 函数,无法删除包括 ST_Raster 列的行,也无法从 SQL 客户端执行 SQL 函数。另外,如果您不配置 Oracle 监听器,则无法将使用 ST_Geometry 类型作为要素服务的数据发布到空间数据服务器。

ST_Raster 安装为可选操作。有关说明,请参阅在 Oracle 中安装 ST_Raster 类型。

注:

如果您的 Oracle 数据库安装在 Windows 服务器上,但您未安装 ArcSDE 应用程序服务器,则您可能需要安装 Microsoft Visual C++ 2008 SP1 Redistributable Package (x64)。如果 Oracle 服务器上没有 Microsoft Visual C++ 2008 SP1 Redistributable Package (x64),则可从 Microsoft 网站下载,然后进行安装。

如果您使用的是 Oracle 11g,请编辑 extproc.ora 文件以通过 Oracle 的外部过程框架来调用函数。如果您使用的是 Oracle 10g,请配置 Oracle 监听器。

3、解决办法

  • st_shapelib.dll
        从desktop中找到st_shapelib.dll文件,找个地儿拷贝下,下面的路径指向该文件
  • 创建ST_SHAPELIB library
       使用sde用户登陆sqlplus

执行sql查询user_libraries
        select * from user_libraries;

        创建ST_SHAPELIB library

create or replace library ST_SHAPELIB as 'C:\arcgisdll\st_shapelib.dll';

 
        设置生效
       alter package sde.st_geometry_shapelib_pkg compile reuse settings;

  • 修改oracle外部代理文件
        找到oracle安装目录下的extproc.ora,并进行修改最后的目录,改为st_shapelib.dll的路径。
        然后进行开始的操作st_astext函数,就ok了==v5

四、总结

  • oracle进行sql查询引入;
  • oracle进行简单sql空间查询;
  • oracle进行空间sql查询出错;
  • oracle空间sql问题解决;
结尾附英文参考:

Setting up your Oracle geodatabase to work with ST_GEOMETRY

Everyone knows about the fact that they need some extra configuration in Oracle, to work with ST_GEOMETRY outside ArcCatalog/ArcMap. The confusion comes about as to what is considered "outside ArcCatalog/ArcMap" and what if ST_GEOMETRY is not their feature shape storage type. This blog post will hopefully help answer some of these questions and also help you with setting up your Oracle geodatabase to work with ST_GEOMETRY.

I would also like to mention that all the information stated here is published by ESRI in various KB articles, documentation, help resources, etc. I am not stating anything new, just consolidating the information to present it in one location for anyone interested.

If you never interact with your geodatabase outside ArcCatalog/ArcMap, then you have nothing to worry about (but come on, when is that really true).

If your feature class storage data type is ST_GEOMETRY and you want to do any sort of spatial queries and/or modify data outside of ArcMap, you will need to set up your geoadatabase for ST_GEOMETRY.

If your feature class storage data type is NOT ST_GEOMETRY, but you would like to query metadata views such as SDE.GDB_ITEMS_VW using SQLPlus or SQLDeveloper, then you will need to set up your geodatabase for ST_GEOMETRY.

If your feature class storage data type is NOT ST_GEOMETRY, and you are not interested in the above mentioned view, then you may not need to set up your geoadatabase for ST_GEOMETRY.

My recommendation would be to set up your geodatabase to work with ST_GEOMETRY anyways. In this way you do not have to worry about it down the road when you plan to work with one of the above features.

Geodatabase Setup

All the steps in the setup are done on the database server. You will need your DBA to perform these steps. The setup consists of 4 steps.

1. ESRI provides a library which is used for ST_GEOMETRY functions and operators with Oracle's external process. This library needs to be on the database server. The library can be found in any ArcGIS Desktop installation under Desktop 10.x\DatabaseSupport Folder. Choose the appropriate RDBMS\DatabaseServerOS directory and you should see a file (for example st_shaplib.dll for Windows OS or libst_shapelib.so for Linux OS). Move the library file to a directory of your choosing on the database server (in this example, I am going to use C:\Oracle\ArcGIS directory as the location of the library file).

In addition, if your database OS is Windows, ensure that the 64-bit Visual C++ 2008 SP1 Redistributable Package is installed, if not, it can be downloaded from Microsoft.

2. Create a library object in the Oracle geodatabase as user SDE. This library object will point to the directory and file (full path) location of the library file located in step 1.

Extending our example from step 1, log into the geodatabase as SDE user and run the following command.

Create or replace library st_shapelib as 'C:\Oracle\ArcGIS\st_shapelib.dll' ;

The name of the library object created in step 2 has to be st_shapelib.

3. Modify the appropriate Oracle files.

If your Oracle version is Oracle 11g and above, then you only need to modify the extproc.ora file located in the ORACLE_HOME\hs\admin directory. The extproc.ora file has a bunch of comments at the top. The line of interest is the last line which is uncommented. In a default state the last line reads

SET EXTPROC_DLLS=

Change this line to below for our example.

SET EXTPROC_DLLS=C:\\Oracle\\ArcGIS\\st_shapelib.dll

if you need to add more than one dll they need to separated by ; in windows and : in Unix/Linux. In windows the path works with \\ and in Unix/Linux the path works with / (I know that is not what the comments above in extproc.ora say, but trust me that is the only way I have gotten it to work)

If your Oracle version is Oracle 10g, then you do not have access to extproc.ora file (was not available in 10g). In this case you have to modify the tnsnames.ora and listener.ora files on the database server, so that the external calls can be made. Both these files are located in the ORACLE_HOME\network\admin directory.

Caution: Before making changes to the tnsnames.ora and listener.ora, please make back up copies of these files.

The tnsnames.ora file contains a directory of known database services (local and remote), one entry is specifically used by the local database server to use external function calls (to the extproc). This entry is labeled EXTPROC_CONNECTION_DATA (must always be labeled by this name). Add/modify the entry in tnsnames.ora

EXTPROC_CONNECTION_DATA =

(DESCRIPTION =

(ADDRESS_LIST = (ADDRESS = (PROTOCOL = IPC)(Key = EXTPROC1)))

(CONNECT_DATA = (SID = PLSExtProc)(PRESENTATION = RO))

)

The next step is to modify listener.ora. Add an entry in the SID_LIST_LISTENER (this is an example of a default listener named LISTENER. If your listener uses a different name then add the entry in its SID_LIST). My entire listener.ora looks like below

LISTENER =

(ADDRESS_LIST =

(ADDRESS= (PROTOCOL= IPC)(KEY = EXTPROC1))

(ADDRESS= (PROTOCOL= TCP)(Host= hostname.domain.com>)(Port= 1521))

)

SID_LIST_LISTENER =

(SID_LIST =

(SID_DESC =

(SID_NAME = PLSExtProc)

(ORACLE_HOME = C:\oracle\product\10.2\db_1)

(PROGRAM = extproc)

(ENVS="EXTPROC_DLLS=C:\Oracle\ArcGIS\st_shapelib.dll")

)

)

The KEY value in listener.ora should match the corresponding service entry in the tnsnames.ora.

Oracle listener files are highly configurable and have lots of additional options. All the possible options that can be configured in the listener.ora and tnsnames.ora are beyond the scope of this blog post. The listener,ora and tnsnames,ora on your database server may look very different from the simple configuration example mentioned above. Please refer to Oracle Database Net Services Administrator's Guide for details about configuring your listeners.

4. In case of Oracle 10g you will need to restart your listener so that the new configuration can be implemented. Creating library objects may cause some of the dependent objects to become invalid. To ensure all the objects in SDE schema are valid, it is a good idea to run recompile on SDE schema as the final step.

Log into the geodatabase as sys user and run the following command.

EXECUTE sys.utl_recomp.recomp_serial('SDE');

This completes the Oracle geodatabase setup to work with ST_GEOMETRY.

ArcGIS——数据库空间SQL(一、oracle中使用sql空间查询及st_astext等函数出错问题)相关推荐

  1. oracle表中增加字段 sql语句,ORACLE中通过SQL语句(alter table)来增加、删除、修改字段...

    1.添加字段: alter table  表名  add (字段  字段类型)  [ default  '输入默认值']  [null/not null]  ; 2.添加备注: comment on ...

  2. oracle清理temp表空间,请问在oracle中temp表空间如何才能释放。

    贴篇metalink的文章 How To Free Temporary Segment in Temporary Tablespace Dynamically Purpose ------- The ...

  3. oracle查询表空间和用户名,教你查询Oracle中的表空间

    教你查询Oracle中的表空间 提到表空间大家可能都不会陌生,它是数据库中最大的逻辑单位与存储空间单位,数据库系统通过表空间为数据库对象分配空间.表空间在物理上体现为磁盘数据文件,每一个表空间由一个或 ...

  4. Oracle 实验五:Oracle中的SQL使用

    实验五:Oracle中的SQL使用 一.实验目的 1.掌握SQL语言中常用系统函数: 2.掌握SQL语言的应用. 二.实验内容 1. 查询SQL中如下常用函数的使用,并举例说明(完成格式参考Lengt ...

  5. sql拼接同一字段中的数据_用SQL将Oracle中同一列的多行记录拼接成一个字符

    用SQL将Oracle中同一列的多行记录拼接成一个字符串 用SQL将Oracle中同一列的多行记录拼接成一个字符串 [sql] -- 原始数据 -- a   111 -- b   222 -- a   ...

  6. 【DB笔试面试605】在Oracle中,SQL概要(SQL Profile)的作用是什么?

    ♣题目 部分 在Oracle中,SQL概要(SQL Profile)的作用是什么? ♣答案部分 SQL Profile就是为某条SQL语句提供除了系统统计信息.对象(表和索引等)统计信息之外的其它信息 ...

  7. mysql的调用有哪三种方式_MySQL数据库之mysql命令行中执行sql的几种方式总结

    本文主要向大家介绍了MySQL数据库之mysql命令行中执行sql的几种方式总结 ,通过具体的内容向大家展现,希望对大家学习MySQL数据库有所帮助. 1.直接输入sql执行 MySQL> se ...

  8. 如何通过数据库SQL Server 2014中的SQL日期格式化语句来转换出我们需要的日期格式化日期时间格式转换的教程方法

    如何通过数据库SQL Server 2014中的SQL日期格式化语句来转换出我们需要的日期格式化日期时间格式转换的教程方法 作者:张国军_Suger 开发工具与关键技术:SQL Server 2014 ...

  9. Oracle中使用SQL根据出生日期精确计算年龄

    Oracle中使用SQL根据出生日期精确计算年龄 提示:以下是本篇文章正文内容,下面案例可供参考 代码如下(示例): select XM,CSNY as 出生日期,-- extract函数用于提取日期 ...

最新文章

  1. 收藏 | 机器学习最全知识点汇总(万字长文)
  2. PHP问题 —— Deprecated: Function ereg_replace() is de
  3. CentOS6.4+rabbitmq集群——源码安装
  4. c语言作业集答案,C语言习题集及答案
  5. python编程从入门到实践 之 数据可视化部分总结和回顾(未完待续)
  6. Severstal: Steel Defect Detection比赛的discussion调研
  7. 【theano-windows】学习笔记二十——LSTM理论及实现
  8. 9年前的大一,我们这样为女生过37女生节【祝节日快乐】
  9. 年终将至,回顾我们一起走过的 2020
  10. 怎样设置电脑壁纸_谷歌地球实时壁纸,电脑和手机实现方案都在这里了
  11. java对【配置文件的读取】与【读配置文件时的路径问题】代码总结
  12. html 好看的英文字体,力荐!8款超有设计感的英文字体。
  13. Kettle中关于多数据库链接报表或视图不存在的错误总结
  14. 开源、个人博客等网站搭建、上云费用控、软件程序爱好者资源集锦
  15. python判断用户名密码是否正确_Python 判断输入的用户名和密码是否正确
  16. 学习和温习sqlserver
  17. 南昌大学计算机学硕和专硕,专硕和学硕哪个好?该怎么选?
  18. 数字后端 - STA
  19. amd 邮件 服务器,[转]免费邮件服务器hMailServer搭配SpamAssassin过滤垃圾邮件:安装和设置...
  20. 十大IT网站排名 及IT论坛(技术社区)排名

热门文章

  1. How to caching Global data in on-chip (level 1) cache in Morden GPU
  2. win32 api简易实现ftp文件上传
  3. 文明重启怎么找回之前的服务器,文明重启房子消失怎么找回 详尽攻略助你一臂之力...
  4. Oracle 12c 读书笔记——筑梦之路
  5. 面向对象:编程范式、类、对象
  6. iOS 的用户认证:使用Swift和Ruby on Rail
  7. 每月一书(202107):《曾国藩的正面与侧面》
  8. vim打开文件跳转到上次编辑的位置
  9. 倭黑猩猩机器人_难以置信!倭黑猩猩竟也有助产“护士”
  10. gitlab 502 Whoops, GitLab is taking too much time to respond.