sde

CREATE TABLE [sde].[HM_V2](
    [OBJECTID] [int] NOT NULL,
    [ID] [int] NULL,
    [CD] [numeric](19, 8) NULL,
    [HG] [numeric](19, 8) NULL,
    [DP_AS] [numeric](19, 8) NULL,
    [CU] [numeric](19, 8) NULL,
    [PB] [numeric](19, 8) NULL,
    [CR] [numeric](19, 8) NULL,
    [ZN] [numeric](19, 8) NULL,
    [NI] [numeric](19, 8) NULL,
    [HM_TIME] [datetime] NULL,
    [HM_NAME] [nvarchar](50) NULL,
    [USER_NAME] [nvarchar](50) NULL,
    [Shape] [int] NULL
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TRIGGER [sc_del_casc_4]
on [sde].[HM_V2] for delete, update
 as
begin
declare @rowcount int
select @rowcount = @@rowcount
if @rowcount = 0
return
 SET NOCOUNT ON
if update(Shape) 
begin
declare @shape_id  int
select @shape_id = Shape from inserted
if (@shape_id IS NULL)
begin
delete SQLSDE.SDE.f4 from deleted d, SQLSDE.SDE.f4 f where d.Shape = f.fid
 delete SQLSDE.SDE.s4 from deleted d, SQLSDE.SDE.s4 s where d.Shape = s.sp_fid
 end 
 else if (select count(*) from deleted where Shape is not null and Shape != @shape_id) > 0
begin
  RAISERROR ('Cannot update spatial column value.',16,-1)
  ROLLBACK
end
return
end     
if (select count(*) from inserted) > 0 
return
delete SQLSDE.SDE.f4 from deleted d, SQLSDE.SDE.f4 f  where d.Shape = f.fid
 delete SQLSDE.SDE.s4 from deleted d, SQLSDE.SDE.s4 s  where d.Shape = s.sp_fid  end
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TRIGGER [sp_col_ins_4]
 on [sde].[HM_V2] for insert
 as if @@rowcount = 0
 return
 if (select count(*) from HM_V2 , inserted where HM_V2.Shape = inserted.Shape) > 1
 RAISERROR ('Duplicate key in Shape column.',16,-1)
 return
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[sde].[SDE_get_version_access]') AND type in (N'FN', N'IF', N'TF', N'FS', N'FT'))
BEGIN
execute dbo.sp_executesql @statement = N'CREATE FUNCTION [sde].[SDE_get_version_access] (
@status INTEGER,
@version_owner NVARCHAR (128))
RETURNS CHAR(1)
BEGIN
--This is a private support function for SDE versioned views.
-- Get the current login & user name
DECLARE @user      NVARCHAR (128)
DECLARE @protected CHAR (1)
DECLARE @is_dba INTEGER
DECLARE @delimiter INTEGER
SELECT @user = user_name()
SET @delimiter = PATINDEX(''"%'', @version_owner)
IF @delimiter > 0
BEGIN
 SET @user = N''"'' + user_name() + N''"''
END
SET @is_dba = sqlsde.sde.SDE_is_user_sde_dba ()
SET @status = @status - floor (@status / 4) * 4
IF @status = 0 -- private version
BEGIN
  IF ((@is_dba = 0) AND (@user <> @version_owner))
    SET @protected = ''2'' -- no permission
  ELSE
    SET @protected = ''0''; -- full permission
END
ELSE IF @status = 2 -- protected version
BEGIN
  IF ((@is_dba = 0) AND (@user <> @version_owner))
    SET @protected = ''1'' -- read only permission
  ELSE
    SET @protected = ''0'' -- full permission
END
ELSE
  SET @protected = ''0'' -- must be a public version
RETURN @protected
END
'
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[HM_POLLUTION_LEVEL]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[HM_POLLUTION_LEVEL](
    [OBJECTID] [numeric](18, 0) NOT NULL,
    [CD_LEVEL] [numeric](10, 0) NOT NULL,
    [HG_LEVEL] [numeric](10, 0) NOT NULL,
    [DP_AS_LEVEL] [numeric](10, 0) NOT NULL,
    [CU_LEVEL] [numeric](10, 0) NOT NULL,
    [PB_LEVEL] [numeric](10, 0) NOT NULL,
    [CR_LEVEL] [numeric](10, 0) NOT NULL,
    [ZN_LEVEL] [numeric](10, 0) NOT NULL,
    [NI_LEVEL] [numeric](10, 0) NOT NULL,
 CONSTRAINT [PK_HM_POLLUTION_LEVEL] PRIMARY KEY CLUSTERED
(
    [OBJECTID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[HM_POLLUTION_LEVEL_DESCRIPTION]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[HM_POLLUTION_LEVEL_DESCRIPTION](
    [OBJECTID] [numeric](18, 0) NOT NULL,
    [CD_LEVEL_DESCRIPTION] [nvarchar](20) NULL,
    [HG_LEVEL_DESCRIPTION] [nvarchar](20) NULL,
    [DP_AS_LEVEL_DESCRIPTION] [nvarchar](20) NULL,
    [CU_LEVEL_DESCRIPTION] [nvarchar](20) NULL,
    [PB_LEVEL_DESCRIPTION] [nvarchar](20) NULL,
    [CR_LEVEL_DESCRIPTION] [nvarchar](20) NULL,
    [ZN_LEVEL_DESCRIPTION] [nvarchar](20) NULL,
    [NI_LEVEL_DESCRIPTION] [nvarchar](20) NULL,
 CONSTRAINT [PK_HM_POLLUTION_LEVEL_DESCRIPTION] PRIMARY KEY CLUSTERED
(
    [OBJECTID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[sde].[SDE_parse_version_name]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [sde].[SDE_parse_version_name]
@version_name NVARCHAR (97),
@parsed_name NVARCHAR (64) OUTPUT,
@parsed_owner NVARCHAR (32) OUTPUT AS SET NOCOUNT ON
BEGIN
  --This is a private support function for SDE versioned views.
  DECLARE @error_string NVARCHAR(256)
  DECLARE @delimiter INTEGER
  DECLARE @SE_INVALID_VERSION_NAME INTEGER
  SET @SE_INVALID_VERSION_NAME = 50171
  -- Parse the version name.
  SET @delimiter = PATINDEX (''%".%'', @version_name)
  IF @delimiter <> 0
  BEGIN
    SET @parsed_owner = substring (@version_name, 1, @delimiter)
    SET @parsed_name = substring (@version_name, @delimiter + 2, 64)
  END
  ELSE
  BEGIN
    SET @delimiter = charindex (''.'', @version_name)
    IF @delimiter <> 0
    BEGIN
      SET @parsed_owner = substring (@version_name, 1, @delimiter - 1)
      SET @parsed_name = substring (@version_name, @delimiter + 1, 64)
    END
    ELSE
    BEGIN
      SET @parsed_name = @version_name
      EXECUTE sqlsde.sde.SDE_get_current_user_name @parsed_owner OUTPUT
    END
  END
  IF RTRIM (@parsed_name) IS NULL OR LEN (@parsed_name) = 0 OR
     RTRIM (@parsed_owner) IS NULL OR LEN (@parsed_owner) = 0
  BEGIN
    SET @error_string = ISNULL (@version_name, ''(null)'') +
                       '' is not a valid version name.''
    RAISERROR (@error_string,16,-1)
    RETURN @SE_INVALID_VERSION_NAME
  END
  RETURN 0
END
'
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[HM_STANDARD]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[HM_STANDARD](
    [OBJECTID] [numeric](18, 0) NOT NULL,
    [CD_STANDARD] [numeric](15, 5) NULL,
    [HG_STANDARD] [numeric](15, 5) NULL,
    [DP_AS_STANDARD] [numeric](15, 5) NULL,
    [CU_STANDARD] [numeric](15, 5) NULL,
    [PB_STANDARD] [numeric](15, 5) NULL,
    [CR_STANDARD] [numeric](15, 5) NULL,
    [ZN_STANDARD] [numeric](15, 5) NULL,
    [NI_STANDARD] [numeric](15, 5) NULL,
 CONSTRAINT [PK_HM_STANDARD] PRIMARY KEY CLUSTERED
(
    [OBJECTID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[sde].[SDE_is_user_sde_dba]') AND type in (N'FN', N'IF', N'TF', N'FS', N'FT'))
BEGIN
execute dbo.sp_executesql @statement = N'CREATE FUNCTION [sde].[SDE_is_user_sde_dba] () RETURNS INTEGER
BEGIN
  --This is a private support function for SDE versioned views.
  DECLARE @user  NVARCHAR (128)
  DECLARE @is_dba INTEGER
  SELECT @user = user_name()
  IF ((@user <> ''sde'') AND (IS_SRVROLEMEMBER (''sysadmin'') <> 1))
  BEGIN
    IF (IS_MEMBER(''db_owner'') <> 1)
      SET @is_dba = 0 -- is not dba
    ELSE
      SET @is_dba = 1 -- is dba
  END
  ELSE
    SET @is_dba = 1 -- is dba
  RETURN @is_dba
END
'
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[sde].[SDE_get_current_user_name]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [sde].[SDE_get_current_user_name]
@current_user NVARCHAR (128) OUTPUT AS SET NOCOUNT ON
BEGIN
 DECLARE @delimiter INTEGER
 DECLARE @owner NVARCHAR(128)
 -- Get current user name. Format the user name as quoted identifier
 -- if the current user name does not comply with the rules for the format of
 -- regular identifiers
 SET @current_user = user_name()
 SET @delimiter = charindex(''~'', @current_user)
 IF @delimiter = 0
   SET @delimiter = charindex (''.'', @current_user)
 IF @delimiter = 0
   SET @delimiter = charindex (''%'', @current_user)
 IF @delimiter = 0
   SET @delimiter = charindex (''^'', @current_user)
 IF @delimiter = 0
   SET @delimiter = charindex (''('', @current_user)
 IF @delimiter = 0
   SET @delimiter = charindex ('')'', @current_user)
 IF @delimiter = 0
   SET @delimiter = charindex (''-'', @current_user)
 IF @delimiter = 0
   SET @delimiter = charindex (''{'', @current_user)
 IF @delimiter = 0
   SET @delimiter = charindex (''}'', @current_user)
 IF @delimiter = 0
   SET @delimiter = charindex ('' '', @current_user)
 IF @delimiter = 0
   SET @delimiter = charindex (''\'', @current_user)
 IF  @delimiter <> 0
 BEGIN
   SET  @current_user = N''"'' + user_name() + N''"''
 END
 -- This stored prcedure will return current user name in upper case format
 -- if the database is case insenstive. In order to know if the database is case
 -- sensitive, here to compare the @current_user to the same string but in upper
 -- case. If they are equal, then the database is case insenstive and uppercase
 -- format of current user name will be returned.
 SET  @owner = UPPER(@current_user)
 IF  @current_user = @owner
   SET  @current_user = @owner
END
'
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[sde].[SDE_generate_guid]'))
EXEC dbo.sp_executesql @statement = N'CREATE VIEW [sde].[SDE_generate_guid] AS
 SELECT ''{'' + CONVERT(NVARCHAR(36),newid()) + ''}'' as guidstr
'
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[sde].[SDE_keyset_delete]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [sde].[SDE_keyset_delete]
@tableNameVal sysname,
@keysetIdVal INTEGER
AS
BEGIN
BEGIN TRAN keyset_tran
DECLARE @sql AS NVARCHAR(256)
SET @sql = N''DELETE FROM sde.'' + @tableNameVal + N''WHERE KEYSET_ID = '' + @keysetIdVal
EXECUTE (@sql)
COMMIT TRAN keyset_tran
END
'
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[sde].[SDE_keyset_remove]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [sde].[SDE_keyset_remove]
@tableNameVal sysname
AS
BEGIN
BEGIN TRAN keyset_tran
DECLARE @sql AS NVARCHAR(256)
SET @sql = N''DROP TABLE sde.'' + @tableNameVal
EXECUTE (@sql)
COMMIT TRAN keyset_tran
END
'
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[sde].[ST_GEOMETRY_COLUMNS]'))
EXEC dbo.sp_executesql @statement = N'CREATE VIEW [sde].[ST_GEOMETRY_COLUMNS] (table_schema, table_name,       column_name, type_schema, type_name,  srs_id) AS        SELECT f_table_schema, f_table_name, f_geometry_column,''dbo'',       CASE geometry_type        WHEN 0 THEN ''ST_GEOMETRY''        WHEN 1 THEN ''ST_POINT''        WHEN 2 THEN ''ST_CURVE''        WHEN 3 THEN ''ST_LINESTRING''        WHEN 4 THEN ''ST_SURFACE''        WHEN 5 THEN ''ST_POLYGON''        WHEN 6 THEN ''ST_COLLECTION''        WHEN 7 THEN ''ST_MULTIPOINT''        WHEN 8 THEN ''ST_MULTICURVE''        WHEN 9 THEN ''ST_MULTISTRING''        WHEN 10 THEN ''ST_MULTISURFACE''        WHEN 11 THEN ''ST_MULTIPOLYGON''        ELSE ''ST_GEOMETRY''        END,        srid FROM sqlsde.sde.SDE_geometry_columns g'
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[sde].[SDE_geocol_def_insert]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [sde].[SDE_geocol_def_insert] @fTabCatVal NVARCHAR(32),     @fTabSchVal NVARCHAR(32), @fTabNameVal sysname, @fGeoColVal NVARCHAR(32), @gTabCatVal     NVARCHAR(32), @gTabSchVal NVARCHAR(32), @gTabNameVal sysname,    @storageTypeVal INTEGER, @geometryTypeVal INTEGER,    @CoordDimensionVal INTEGER, @sridVal INTEGER AS    SET NOCOUNT ON    BEGIN    BEGIN TRAN geocol_insert    INSERT INTO sqlsde.sde.SDE_geometry_columns (f_table_catalog,f_table_schema,f_table_name, f_geometry_column,     g_table_catalog,g_table_schema,g_table_name,storage_type, geometry_type,    coord_dimension, srid) VALUES ( @fTabCatVal, @fTabSchVal,    @fTabNameVal, @fGeoColVal, @gTabCatVal, @gTabSchVal, @gTabNameVal,    @storageTypeVal, @geometryTypeVal, @CoordDimensionVal, @sridVal)    COMMIT TRAN geocol_insert    END'
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[sde].[SDE_layer_def_update]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [sde].[SDE_layer_def_update]
@descVal NVARCHAR(65), @g1Val FLOAT, @g2Val FLOAT, @g3Val FLOAT,
@minxVal FLOAT, @minyVal FLOAT, @maxxVal FLOAT, @maxyVal FLOAT,
@minzVal FLOAT, @maxzVal FLOAT, @minmVal FLOAT, @maxmVal FLOAT,
@efVal INTEGER, @layerMaskVal INTEGER, @layerConVal  NVARCHAR(32),
@optArrSize INTEGER, @statDateVal INTEGER, @minIdVal INTEGER,
@layerIdVal INTEGER, @geometryTypeVal INTEGER, @secondarySridVal INTEGER AS
SET NOCOUNT ON
UPDATE sqlsde.sde.SDE_layers
SET description = @descVal, gsize1 = @g1Val, gsize2 = @g2Val,
  gsize3 = @g3Val, minx = @minxVal, miny = @minyVal, maxx = @maxxVal,
  maxy = @maxyVal, minz = @minzVal, maxz = @maxzVal, minm = @minmVal,
  maxm = @maxmVal, eflags = @efVal, layer_mask = @layerMaskVal,
  layer_config = @layerConVal, optimal_array_size = @optArrSize,
  stats_date = @statDateVal, minimum_id = @minIdVal, secondary_srid = @secondarySridVal
WHERE layer_id = @layerIdVal
UPDATE sqlsde.sde.SDE_geometry_columns
SET geometry_type = @geometryTypeVal
FROM sqlsde.sde.SDE_layers l
WHERE l.layer_id = @layerIdVal AND l.database_name = f_table_catalog
  AND l.owner = f_table_schema AND l.table_name = f_table_name AND
  l.spatial_column = f_geometry_column'
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[sde].[SDE_geocol_def_delete]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [sde].[SDE_geocol_def_delete]                 @fTableCatalogVal NVARCHAR(32), @fTableSchemaVal NVARCHAR(32),                @fTableNameVal sysname, @fGeometryColumnVal NVARCHAR(32) AS                 SET NOCOUNT ON                BEGIN                BEGIN TRAN geocol_delete                DELETE FROM sqlsde.sde.SDE_geometry_columns WHERE f_table_catalog = @fTableCatalogVal AND                 f_table_schema = @fTableSchemaVal AND                 f_table_name = @fTableNameVal AND                 f_geometry_column = @fGeometryColumnVal                COMMIT TRAN geocol_delete                END'
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[sde].[SDE_geocol_def_change_table_name]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [sde].[SDE_geocol_def_change_table_name]              @tabNameVal sysname, @layerIdVal INTEGER AS SET NOCOUNT ON             UPDATE sqlsde.sde.SDE_geometry_columns SET f_table_name = @tabNameVal FROM sqlsde.sde.SDE_geometry_columns INNER JOIN sqlsde.sde.SDE_layers ON (            (sqlsde.sde.SDE_geometry_columns.f_table_catalog = sqlsde.sde.SDE_layers.database_name) AND             (sqlsde.sde.SDE_geometry_columns.f_table_schema = sqlsde.sde.SDE_layers.owner) AND             (sqlsde.sde.SDE_geometry_columns.f_table_name = sqlsde.sde.SDE_layers.table_name) AND             (sqlsde.sde.SDE_geometry_columns.f_geometry_column =  sqlsde.sde.SDE_layers.spatial_column) )              WHERE layer_id= @layerIdVal'
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[sde].[SDE_layer_srid_update]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [sde].[SDE_layer_srid_update]              @sridVal INTEGER, @layeridVal INTEGER AS SET NOCOUNT ON BEGIN              DECLARE @g_table sysname              SET @g_table = N''f'' + cast(@layeridVal as NVARCHAR)              UPDATE sqlsde.sde.SDE_layers SET srid = @sridVal WHERE layer_id = @layeridVal
 UPDATE             sqlsde.sde.SDE_geometry_columns SET srid = @sridVal WHERE g_table_name = @g_table END'
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[sde].[SDE_layer_def_envelope_update]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [sde].[SDE_layer_def_envelope_update]              @minxVal FLOAT, @minyVal FLOAT, @maxxVal FLOAT,              @maxyVal FLOAT, @minzVal FLOAT, @maxzVal FLOAT,              @minmVal FLOAT, @maxmVal FLOAT, @layeridVal INTEGER AS              SET NOCOUNT ON              BEGIN             BEGIN TRAN layer_env_update             UPDATE sqlsde.sde.SDE_layers              SET minx = @minxVal,              miny = @minyVal,              maxx = @maxxVal,              maxy = @maxyVal,              minz = @minzVal,              maxz = @maxzVal,              minm = @minmVal,              maxm = @maxmVal              WHERE layer_id = @layeridVal             COMMIT TRAN layer_env_update             END'
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[sde].[SDE_layer_def_mask_update]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [sde].[SDE_layer_def_mask_update]              @maskVal INTEGER, @layeridVal INTEGER AS              SET NOCOUNT ON              BEGIN             BEGIN TRAN layer_mask_update             UPDATE sqlsde.sde.SDE_layers              SET layer_mask = @maskVal              WHERE layer_id = @layeridVal             COMMIT TRAN layer_mask_update             END'
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[sde].[SDE_layer_def_change_table_name]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [sde].[SDE_layer_def_change_table_name]              @tabNameVal sysname, @layerIdVal INTEGER AS SET NOCOUNT ON             UPDATE sqlsde.sde.SDE_layers SET              table_name = @tabNameVal  WHERE layer_id = @layerIdVal'
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[sde].[SDE_layer_def_insert]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [sde].[SDE_layer_def_insert]
@layerIdVal INTEGER, @descVal NVARCHAR(65),@dbNameVal NVARCHAR(32),
@tabNameVal sysname, @ownerVal NVARCHAR(32), @spColVal NVARCHAR(32),
@eflagsVal INTEGER, @layerMaskVal INTEGER, @gsize1Val FLOAT, @gsize2Val FLOAT,
@gsize3Val FLOAT,@minxVal FLOAT,@minyVal FLOAT, @maxxVal FLOAT, @maxyVal FLOAT,
@minzVal FLOAT, @maxzVal FLOAT,@minmVal FLOAT, @maxmVal FLOAT, @cdateVal INTEGER,
@layerConfigVal NVARCHAR(32),@optArraySizeVal INTEGER, @statsDateVal INTEGER,
@minIdVal INTEGER, @sridVal INTEGER, @baseId INTEGER, @secondarySridVal INTEGER AS
SET NOCOUNT ON
BEGIN
BEGIN TRAN layer_insert
INSERT INTO sqlsde.sde.SDE_layers (layer_id,description,database_name,table_name,owner,
spatial_column,eflags,layer_mask,gsize1,gsize2,gsize3,minx,miny,maxx,maxy,
minz,maxz,minm, maxm,cdate,layer_config,optimal_array_size,stats_date,
minimum_id,srid,base_layer_id,secondary_srid) VALUES (@layerIdVal, @descVal,
@dbNameVal, @tabNameVal,
@ownerVal, @spColVal,@eflagsVal, @layerMaskVal, @gsize1Val, @gsize2Val, @gsize3Val,
@minxVal, @minyVal, @maxxVal, @maxyVal,@minzVal, @maxzVal, @minmVal, @maxmVal,
@cdateVal,@layerConfigVal, @optArraySizeVal, @statsDateVal, @minIdVal, @sridVal,
@baseId, @secondarySridVal)
COMMIT TRAN layer_insert
END'
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[sde].[SDE_geocol_def_update]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [sde].[SDE_geocol_def_update]             @layerIdVal INTEGER, @srTextVal TEXT, @xycluster_tolVal FLOAT,            @zcluster_tolVal FLOAT, @mcluster_tolVal FLOAT AS SET NOCOUNT ON            UPDATE sqlsde.sde.SDE_spatial_references SET srtext = @srTextVal,            xycluster_tol = @xycluster_tolVal, zcluster_tol = @zcluster_tolVal,            mcluster_tol = @mcluster_tolVal WHERE srid  in (SELECT srid            FROM sqlsde.sde.SDE_layers WHERE layer_id = @layerIdVal)'
END
GO


你可能感兴趣的:(数据库,dfe)