|
rammohan
Posting Yak Master
212 Posts |
Posted - 2008-10-17 : 10:10:38
|
| Hi, I have created a Scaler valued function and I am trying to use it in a Stored Proc. Everything was fine, My SP created sucessfully. But when I execute that SP, get this error-Cannot find either column "dbo" or the user-defined function or aggregate "dbo.Split", or the name is ambiguous.Function Code- USE [Accounts]CREATE FUNCTION [dbo].[Spilt] ( @Array VARCHAR(1000), @separator VARCHAR(10),@number INT) RETURNS VARCHAR(100)ASBEGINDECLARE @parseValue VARCHAR(100)DECLARE @RetValue VARCHAR(100)DECLARE @separator_position INT DECLARE @array_value VARCHAR(1000) SET @array = @array +@separatorDECLARE @Num INT;SET @Num =len(replace(isnull(@Array, ''), @separator, @separator + ' ')) - len(isnull(@Array, '')) + case when ltrim(isnull(@Array, '')) <> '' then 1 else 0 end WHILE patindex('%' + @separator + '%' , @array) <> 0 BEGIN SELECT @separator_position = patindex('%' + @separator + '%', @array) SELECT @array_value = left(@array, @separator_position - 1) SET @parseValue= Cast(@array_value AS varchar) SELECT @array = stuff(@array, 1, @separator_position, '') IF(@Num = @number) SET @RetValue = @parseValue;--REVERSE(@parseValue); SET @Num = @Num-1; END RETURN @RetValue END Procedure CREATE PROC [dbo].[ax_InsertTransaction](@VID INT,@LedgerIDs VARCHAR(1000),@Amounts VARCHAR(1000),@TransType VARCHAR(500))ASdeclare @index intdeclare @separator char(1)set @separator = ',';DECLARE @LID INTSET @LID =0;DECLARE @Amount moneyset @Amount =cast(0 as money);DECLARE @TT CHAR(1)SET @TT = ' ';DECLARE @COUNT INT;SET @COUNT = len(replace(isnull(@LedgerIDs, ''), @separator, @separator + ' ')) - len(isnull(@LedgerIDs, '')) + case when ltrim(isnull(@LedgerIDs, '')) <> '' then 1 else 0 end BEGIN while ( @COUNT >=1) BEGIN SET @LID = CAST([dbo].[Split](@LedgerIDs,',',@COUNT) AS INT) SET @Amount = cast([dbo].[Split](@LedgerIDs,',',@COUNT) AS MONEY) SET @TT = cast([dbo].[Split](@LedgerIDs,',',@COUNT) AS CHAR(1)) INSERT INTO Transactions (VID, LID,Amount, TransType, Status, CreatedOn) VALUES (@VID, @LID,@Amount,@TT,'true',getdate()) SET @COUNT = @COUNT-1; END END Any helps appreciated....One can never consent to creep,when one feels an impulse to soarRAMMOHAN |
|