--
-- Backwards compatible sp:
-- Use old sp_add_datatype_mapping to create a new
-- call to sp_MSrepl_adddatatypemapping.
-- This sp always maps MS SQL Server to a target DBMS.
--
create procedure sys.sp_add_datatype_mapping
(
@dbms_name sysname,
@sql_type sysname,
@dest_type sysname,
@dest_prec int,
@dest_create_params int,
@dest_nullable bit
)
as
BEGIN
DECLARE @dest_length bigint
DECLARE @dest_precision bigint
DECLARE @dest_scale int
SELECT @dest_length = NULL,
@dest_precision = NULL,
@dest_scale = NULL
set nocount on
if @dbms_name is null
BEGIN
RAISERROR (14043, 16, -1, '@dbms_name', 'sp_add_datatype_mapping')
RETURN (1)
END
if @sql_type is null
BEGIN
RAISERROR (14043, 16, -1, '@sql_type', 'sp_add_datatype_mapping')
RETURN (1)
END
if @dest_type is null
BEGIN
RAISERROR (14043, 16, -1, '@dest_type', 'sp_add_datatype_mapping')
RETURN (1)
END
if @dest_prec is null
BEGIN
RAISERROR (14043, 16, -1, '@dest_prec', 'sp_add_datatype_mapping')
RETURN (1)
END
if @dest_create_params is null
BEGIN
RAISERROR (14043, 16, -1, '@dest_create_params', 'sp_add_datatype_mapping')
RETURN (1)
END
if @dest_nullable is null
BEGIN
RAISERROR (14043, 16, -1, '@dest_nullable', 'sp_add_datatype_mapping')
RETURN (1)
END
-- Use create params to determine what the source / destination
-- settings should be
IF (@dest_create_params & 1) = 1
BEGIN
-- Precision
SET @dest_precision = @dest_prec
END
IF ((@dest_create_params & 4) = 4) OR (@dest_create_params = 0)
BEGIN
-- Length
SET @dest_length = @dest_prec
END
IF (@dest_create_params & 2) = 2
BEGIN
-- Scale
SET @dest_scale = 0
END
-- Add data type mapping
exec sp_MSrepl_adddatatypemapping @source_dbms = 'MSSQLSERVER',
@source_version = NULL,
@source_type = @sql_type,
@destination_dbms = @dbms_name,
@destination_version = NULL,
@destination_type = @dest_type,
@destination_length = @dest_length,
@destination_precision = @dest_precision,
@destination_scale = @dest_scale,
@destination_nullable = @dest_nullable,
@destination_createparams = @dest_create_params
if @@error <> 0
return(1)
END
|