您的位置:首页 > 其它

一种快速批量创建子版本的方法

2012-03-12 09:35 441 查看
经常使用ArcGIS版本编辑的用户经常会为随着时间越来越长,查询和编辑效率下降所苦恼,而且用户也都明白只能使用版本压缩来解决这个问题,但是想要彻底的进行版本压缩,首先必须将相关的子版本名称给删除掉,这是让人很头疼的事情,因为有些用户的业务是多用户编辑的,可能这个业务创建了几十个版本,也有相关的父子版本,那么每次都要删除再重新创建,肯定会让用户崩溃的,但是不删除又不能彻底的进行版本压缩,这就成为了一个矛盾。

其实这个没有关系,ArcSDE提供了创建版本的存储过程,我么可以将我们的业务进行梳理,写一个批处理的SQL语句就可以解决了。

让我们看看这个存储过程

SQL> desc sde.version_user_ddl
FUNCTION CHECK_MV_RELEASE RETURNS NVARCHAR2
PROCEDURE CREATE_VERSION
参数名称                       类型                    输入/输出默认值?
------------------------------ ----------------------- ------ --------
 PARENT_NAME                    NVARCHAR2(97)           IN
 NAME                           NVARCHAR2(97)           IN/OUT
 NAME_RULE                      BINARY_INTEGER          IN
 ACCESS                         BINARY_INTEGER          IN
 DESCRIPTION                    NVARCHAR2               IN

//我们来看看分别表示什么?
//其中权限当然有private、public、protected,这几个参数也可以使用数字表示
EXEC sde.version_user_ddl.create_version (
                sde.DEFAULT’, ---------------父版本   
                :mv_version, ---------------子版本 
                sde.version_util.C_take_name_as_given,
                sde.version_util.C_version_private,--------权限                   
              'multiversioned view edit version');------版本描述

For the name argument: 

• sde.version_util.C_take_name_as_given attempts to use the name provided and if a version exists owned by the user, an error will be encountered. 
• sde.version_util.C_generate_unique_name ensures the input name is unique if there is an existing version with the same name owned by the user. If the objective is to ensure a version is created, use the C_generate_unique_name constant and check the OUT argument value for name. 

For the access argument: 

• sde.version_util.C_version_private creates the version as private. Only the owner and SDE administrator are able to access the version. 
• sde.version_util.C_version_public creates the version as public. All users are able to access the version. 
• sde.version_util.C_version_protected creates the version as protected. All users may view the version, but only the owner and SDE administrator may edit the version.


但是子版本不能直接使用名称,直接使用名称会报错

SQL> exec sde.version_user_ddl.create_version('SDE.DEFAULT','V1',sde.version_util.C_take_name_as_given,sde.version_util.
C_version_private,'create version name v1 from sde.default');
BEGIN sde.version_user_ddl.create_version('SDE.DEFAULT','V1',sde.version_util.C_take_name_as_given,sde.version_util.C_ve
rsion_private,'create version name v1 from sde.default'); END;

                                                        *
第 1 行出现错误:
ORA-06550: 第 1 行, 第 57 列:
PLS-00363: 表达式 'V1' 不能用作赋值目标
ORA-06550: 第 1 行, 第 7 列:
PL/SQL: Statement ignored


我们需要定义个子版本的变量即可
// mv_version 为变量名,NVARCHAR2(10) 为变量的数据类型
VARIABLE mv_version NVARCHAR2(10);
// mvedits 为版本名称
EXEC :mv_version := 'mvedits';
那么根据上面所述,我们就可以来完成以下的例子了



我们需要创建一个类似上面的版本结构

variable mv_version nvarchar2(10);
/
exec :mv_version:='V1';
/
exec sde.version_user_ddl.create_version('sde.DEFAULT',:mv_version,sde.version_util.C_take_name_as_given,sde.version_util.C_version_private,'create version name v1 from sde.default');
/
exec :mv_version:='V11';
/
exec sde.version_user_ddl.create_version('V1',:mv_version,sde.version_util.C_take_name_as_given,sde.version_util.C_version_private,'create version name v11 from v1');
/
exec :mv_version:='V12';
/
exec sde.version_user_ddl.create_version('V1',:mv_version,sde.version_util.C_take_name_as_given,sde.version_util.C_version_private,'create version name v12 from v1');
/
exec :mv_version:='V13';
/
exec sde.version_user_ddl.create_version('V1',:mv_version,sde.version_util.C_take_name_as_given,sde.version_util.C_version_private,'create version name v13 from v1');
/
exec :mv_version:='V2';
/
exec sde.version_user_ddl.create_version('sde.DEFAULT',:mv_version,sde.version_util.C_take_name_as_given,sde.version_util.C_version_private,'create version name v2 from sde.default');
/
exec :mv_version:='V21';
/
exec sde.version_user_ddl.create_version('V2',:mv_version,sde.version_util.C_take_name_as_given,sde.version_util.C_version_private,'create version name v21 from v2');
/
上面是编写的相关文件,然后连接用户执行即可
C:\Users\Administrator>sqlplus sde/sde@orcl_165

SQL*Plus: Release 11.2.0.1.0 Production on 星期三 3月 7 16:39:13 2012

Copyright (c) 1982, 2010, Oracle.  All rights reserved.

连接到:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> @ d:\1.sql
SP2-0103: SQL 缓冲区中无可运行的程序。

PL/SQL 过程已成功完成。

SP2-0103: SQL 缓冲区中无可运行的程序。

PL/SQL 过程已成功完成。

SP2-0103: SQL 缓冲区中无可运行的程序。

PL/SQL 过程已成功完成。

SP2-0103: SQL 缓冲区中无可运行的程序。

PL/SQL 过程已成功完成。

SP2-0103: SQL 缓冲区中无可运行的程序。

PL/SQL 过程已成功完成。

SP2-0103: SQL 缓冲区中无可运行的程序。

PL/SQL 过程已成功完成。

SP2-0103: SQL 缓冲区中无可运行的程序。

PL/SQL 过程已成功完成。

SP2-0103: SQL 缓冲区中无可运行的程序。

PL/SQL 过程已成功完成。

SP2-0103: SQL 缓冲区中无可运行的程序。

PL/SQL 过程已成功完成。

SP2-0103: SQL 缓冲区中无可运行的程序。

PL/SQL 过程已成功完成。

SP2-0103: SQL 缓冲区中无可运行的程序。

PL/SQL 过程已成功完成。

SP2-0103: SQL 缓冲区中无可运行的程序。

PL/SQL 过程已成功完成。
然后我们使用ArcGIS Desktop10.1查看版本关系(新特性啊)



所以,以后如果有上面需求,使用这种方法创建,肯定是非常高效的。

PS:其实这个存储过程也提供了删除版本的方法

EXEC sde.version_user_ddl.delete_version('mv_version');
在批量删除版本方法是类似的
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: