text: if exists (select * from INFORMATION_SCHEMA.ROUTINES where ROUTINE_NAME = 'spGRIDVIEWS_COLUMNS_InsModule' and ROUTINE_TYPE = 'PROCEDURE')
  	Drop Procedure dbo.spGRIDVIEWS_COLUMNS_InsModule;
  GO
   
  /**********************************************************************************************************************
   * Copyright (C) 2005-2022 SplendidCRM Software, Inc. 
   * MIT License
   * 
   * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation 
   * files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, 
   * modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software 
   * is furnished to do so, subject to the following conditions:
   * 
   * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
   * 
   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 
   * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 
   * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR 
   * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
   *********************************************************************************************************************/
  -- 09/02/2010 Paul.  Inserting a module should be very similar to inserting a HyperLink. 
  -- 10/09/2010 Paul.  Add PARENT_FIELD so that we can establish dependent listboxes. 
  -- 10/30/2013 Paul.  Increase size of URL_TARGET. 
  Create Procedure dbo.spGRIDVIEWS_COLUMNS_InsModule
  	( @GRID_NAME                   nvarchar( 50)
  	, @COLUMN_INDEX                int
  	, @HEADER_TEXT                 nvarchar(150)
  	, @DATA_FIELD                  nvarchar( 50)
  	, @SORT_EXPRESSION             nvarchar( 50)
  	, @ITEMSTYLE_WIDTH             nvarchar( 10)
  	, @ITEMSTYLE_CSSCLASS          nvarchar( 50)
  	, @URL_FIELD                   nvarchar(max)
  	, @URL_FORMAT                  nvarchar(max)
  	, @URL_TARGET                  nvarchar( 60)
  	, @URL_MODULE                  nvarchar( 25)
  	, @URL_ASSIGNED_FIELD          nvarchar( 30)
  	)
  as
    begin
  
  	declare @ID        uniqueidentifier;
  	declare @COLUMN_ID uniqueidentifier;
  	
  	-- BEGIN Oracle Exception
  		select @ID = ID
  		  from GRIDVIEWS_COLUMNS
  		 where GRID_NAME    = @GRID_NAME
  		   and COLUMN_INDEX = @COLUMN_INDEX
  		   and DELETED      = 0            
  		   and DEFAULT_VIEW = 0            ;
  	-- END Oracle Exception
  	if not exists(select * from GRIDVIEWS_COLUMNS where ID = @ID) begin -- then
  		-- GRID_NAME, COLUMN_INDEX, COLUMN_TYPE, HEADER_TEXT, DATA_FIELD, SORT_EXPRESSION, ITEMSTYLE_WIDTH
  		exec dbo.spGRIDVIEWS_COLUMNS_Update
  			  @COLUMN_ID out
  			, null
  			, @GRID_NAME
  			, @COLUMN_INDEX
  			, N'TemplateColumn'
  			, @HEADER_TEXT
  			, @SORT_EXPRESSION
  			, @ITEMSTYLE_WIDTH
  			, @ITEMSTYLE_CSSCLASS
  			, null
  			, null
  			, null
  			, @DATA_FIELD
  			, N'HyperLink'
  			, @URL_FIELD
  			, @URL_FORMAT
  			, @URL_TARGET
  			, null
  			, @URL_MODULE
  			, @URL_ASSIGNED_FIELD
  			, @URL_MODULE
  			, null             -- PARENT_FIELD      
  			;
  	end -- if;
    end
  GO
   
  Grant Execute on dbo.spGRIDVIEWS_COLUMNS_InsModule to public;
  GO
   
  