Hi,
When ever I am trying to execute the below stored procedure I get this error:
Msg 4121, Level 16, State 1, Procedure create_or_replace_device, Line 46
Cannot find either column "xyz_account" or the user-defined function or aggregate "xyz_account.is_hex", or the name is ambiguous.
USE [abc]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER OFF
GO
ALTER PROCEDURE [dbo].[create_or_replace_device] (
@iext_account_id varchar(30),
@iserial_number varchar(40),
@imanufacturer varchar(40),
@ihardware_type varchar(20),
@ioutlet varchar(25),
@iaction varchar(20),
@result int output,
@oSqlCode int output,
@oSqlErrm varchar(500) output)
as
BEGIN
declare @l_dev_rec_accountid int
declare @l_dev_rec_status varchar(20)
declare @l_dev_rec_devicetype varchar(20)
declare @l_dev_rec_outlet varchar(25)
declare @l_device_type varchar(20);
declare @l_status varchar(20);
declare @l_accountid int;
declare @l_networkid int;
declare @l_da_type int;
declare @p_tmpRIGHTNOW datetime
set @p_tmpRIGHTNOW = getdate()
set @oSqlCode = 0;
set @oSqlErrm = '';
set @result = 0;
IF (@iext_account_id is null) begin
set @result = 2010;
return;
END ;
IF (@iserial_number is null) begin
set @result = 2020;
return;
END ;
IF (len(@iserial_number) > 12) begin
set @result = 2021;
return;
end;
if (cast(upper(@iSerial_number) as varbinary) <> cast(@iSerial_number as varbinary)
or xyz_account.is_hex(@iSerial_number)= 0) begin
set @result = 2021;
return;
END ;
IF (@imanufacturer is null) begin
set @result = 2030;
return;
END ;
IF (len(@imanufacturer) > 40) begin
set @result = 2031;
return;
END ;
IF (@ihardware_type is null) begin
set @result = 2040;
return;
END ;
IF (len(@ihardware_type) > 3) begin
set @result = 2041;
return;
END ;
IF (len(@ioutlet) > 25) begin
set @result = 2050;
return;
END ;
IF (@iaction is null) begin
set @result = 2060;
return;
END ;
set @l_da_type = CASE @ihardware_type WHEN 'STU' THEN 0 WHEN 'PRR' THEN 0 WHEN 'SCD' THEN 1 end
IF @l_da_type is NULL begin
set @result = 2041;
return;
END
begin try
SELECT @l_accountid=accountid,@l_networkid=networkid FROM oact_tbl_accounts
WHERE extaccountid = @iext_account_id
if @l_accountid is null begin
set @result = 2011;
return;
end
exec map2device_type @imanufacturer, @ihardware_type, @l_device_type output
set @l_status = CASE @iaction WHEN 'i' THEN 'INACTIVE' WHEN 'a' THEN 'ACTIVE' WHEN 'd' THEN 'REMOVED' END;
IF (@l_status is NULL) begin
set @result = 2061;
return;
END
SELECT @l_dev_rec_accountid=accountid, @l_dev_rec_status=status,
@l_dev_rec_devicetype = devicetype, @l_dev_rec_outlet=outlet
FROM oact_tbl_devices WHERE deviceid = @iserial_number;
if @l_dev_rec_accountid is not null begin
IF @l_dev_rec_devicetype <> @l_device_type begin
set @result = 2042;
return;
END;
IF (@l_dev_rec_accountid <> @l_accountid OR @l_dev_rec_status <> @l_status
OR isnull(@l_dev_rec_outlet,'') <> isnull(@ioutlet,'')) begin
UPDATE oact_tbl_devices
SET accountid = @l_accountid, status = @l_status, networkid = @l_networkid, outlet = @ioutlet,
updatedby = 'SMS Adapter', updatedon = getdate()
WHERE deviceid = @iserial_number;
IF @l_dev_rec_status <> @l_status begin
update oact_tbl_digital_addresses set status = @l_status WHERE deviceid = @iserial_number;
END
END ;
end
else begin
exec add_device_and_da @l_accountid, @l_networkid,@iserial_number,@l_da_type, @l_device_type,@ioutlet,@l_status
end
end try
begin catch
set @result = 2990;
set @oSqlCode = error_number();
set @oSqlErrm = error_message();
end catch
end
Please help me with this.