Re: User defined function problem
From: babz (babz_at_discussions.microsoft.com)
Date: 10/26/04
- Next message: Roji. P. Thomas: "Re: strange sp problem"
- Previous message: Uri Dimant: "Re: Aggregated date range query"
- In reply to: Narayana Vyas Kondreddi: "Re: User defined function problem"
- Messages sorted by: [ date ] [ thread ]
Date: Mon, 25 Oct 2004 22:43:02 -0700
Thanx a lot friends
"Narayana Vyas Kondreddi" wrote:
> It will work fine, if you call the function as shown below:
>
> Select * from dbo.udfSelSplittedCodes1('1,2,3', default, default)
>
> This is documented in the CREATE FUNCTION page of Books Online.
> --
> HTH,
> Vyas, MVP (SQL Server)
> SQL Server Articles and Code Samples @ http://vyaskn.tripod.com/
>
>
> "babz" <babz@discussions.microsoft.com> wrote in message
> news:66467612-25F2-4D5D-ABE9-87AFC869D827@microsoft.com...
> I am using a function to split the delimited separated codes,
>
> CREATE FUNCTION dbo.udfSelSplittedCodes1
>
> ( @CdString VARCHAR(8000)
> , @RowDelimiter CHAR(1) = ','
> , @ColDelimiter CHAR(1) = ':'
> )
> RETURNS @tblCodes TABLE (Cd INT)
> AS
> BEGIN
>
>
> DECLARE @RetVal int
> ,@ErrMsg varchar(255)
> ,@SPRetVal int
>
> DECLARE @error int /* Error Code */
>
>
> WHILE CharIndex(@RowDelimiter, @CdString) > 1
> BEGIN
> INSERT INTO @tblCodes (Cd)
> VALUES (SubString(@CdString, 1, CharIndex(@RowDelimiter, @CdString)-1))
> SELECT @CdString = SubString(@CdString, CharIndex(@RowDelimiter,
> @CdString)+ 1 , Len(@CdString))
> SELECT @Error = @@Error
>
> END
> INSERT INTO @tblCodes (Cd)
> VALUES (@CdString)
> SELECT @Error = @@Error
>
> Return
>
>
> END
>
> It is working fine if i am passing all the paramters.
>
> Select * from dbo.udfSelSplittedCodes1('1,2,3', ',', ':')
>
> but if i ignored the second and third param in my query
>
> Select * from dbo.udfSelSplittedCodes1('1,2,3')
>
> it is giving me 'insufficient number of arguments supplied error'.
>
> In my function i have given default values for second and third params
>
> And more over how to raiseerror in function.
>
>
>
>
>
>
>
>
>
>
>
>
- Next message: Roji. P. Thomas: "Re: strange sp problem"
- Previous message: Uri Dimant: "Re: Aggregated date range query"
- In reply to: Narayana Vyas Kondreddi: "Re: User defined function problem"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|