Professional Web Applications Themes

UDFs with default parameters - doesn't work? - Microsoft SQL / MS SQL Server

I seem to be able to use the default parameter syntax in declaring a UDF, but when I call it from the Query yzer, it still requires the optional parameter!   That's all fine.   That's fine.   Server: Msg 313, Level 16, State 2, Line 1 An insufficient number of arguments were supplied for the procedure or function dbo.strClean. -- SQL2K sp1. Is this a malfunction, and does it still malfunction in SP3? Thanks. Joshua Stern...

  1. #1

    Default UDFs with default parameters - doesn't work?

    I seem to be able to use the default parameter syntax in declaring a
    UDF, but when I call it from the Query yzer, it still requires the
    optional parameter!
     

    That's all fine.
     

    That's fine.
     

    Server: Msg 313, Level 16, State 2, Line 1
    An insufficient number of arguments were supplied for the procedure or
    function dbo.strClean.

    --

    SQL2K sp1.

    Is this a malfunction, and does it still malfunction in SP3?

    Thanks.

    Joshua Stern


    JXStern Guest

  2. #2

    Default Re: UDFs with default parameters - doesn't work?

    User the keyword "Default" when calling the UDF.
    dbo.strClean('abc',default) as cleanText

    "JXStern" <net> wrote in message
    news:com... 
    >
    > That's all fine.

    >
    > That's fine.

    >
    > Server: Msg 313, Level 16, State 2, Line 1
    > An insufficient number of arguments were supplied for the procedure or
    > function dbo.strClean.
    >
    > --
    >
    > SQL2K sp1.
    >
    > Is this a malfunction, and does it still malfunction in SP3?
    >
    > Thanks.
    >
    > Joshua Stern
    >
    >[/ref]


    raydan Guest

  3. #3

    Default Re: UDFs with default parameters - doesn't work?

    Nope. You cannot omit any parameter in your function call whether or not it
    has a default value. If you do not want to pass in a value, you must tell
    the system to use the default one.

    e.g.
    create function dbo._fn(i int=123)
    returns varchar(255)
    as
    begin
    return(select 'your value is: '+cast(i as varchar))
    end
    go

    select dbo._fn(456)
    select dbo._fn(default)
    go



    --
    -oj
    RAC v2.2 & QALite!
    http://www.rac4sql.net


    "JXStern" <net> wrote in message
    news:com... 
    >
    > That's all fine.

    >
    > That's fine.

    >
    > Server: Msg 313, Level 16, State 2, Line 1
    > An insufficient number of arguments were supplied for the procedure or
    > function dbo.strClean.
    >
    > --
    >
    > SQL2K sp1.
    >
    > Is this a malfunction, and does it still malfunction in SP3?
    >
    > Thanks.
    >
    > Joshua Stern
    >
    >[/ref]


    oj Guest

  4. #4

    Default Re: UDFs with default parameters - doesn't work?

    On Mon, 4 Aug 2003 13:48:10 -0400, "raydan"
    <nospamcom> wrote: 

    Foo, got my languages confused. Might as well just require it.

    Thanks.

    J.


    JXStern Guest

Similar Threads

  1. Default Page parameters
    By Tami_Gottschalk@adobeforums.com in forum Adobe Indesign Macintosh
    Replies: 3
    Last Post: November 16th, 07:18 PM
  2. New default doent type with parameters
    By adam.ratcliffe@gmail.com in forum Macromedia Exchange Dreamweaver Extensions
    Replies: 0
    Last Post: December 24th, 09:21 AM
  3. passing parameters to a script doesn't work
    By Sol in forum PHP Development
    Replies: 1
    Last Post: September 23rd, 04:34 AM
  4. why doesn't default values for this function work
    By Anders Thoresson in forum PHP Development
    Replies: 3
    Last Post: August 5th, 07:19 PM
  5. Replies: 2
    Last Post: August 5th, 06:35 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139