2 Replies Latest reply on Aug 9, 2013 3:15 PM by iccsi

    optional cfprocparam

    iccsi Level 1

      I have an optional parameter in my stored procedure.

      I call the procedure from my function in cfc file.

      The code is following.

      Since the Myparam3 is not required in myfunction, neither in stored procedure.


      It does not return data if I do not provide 3 parameter from my html link.

      It does return the data I need if I provide MyParam3 to MyFunction,

      Do I need provide the not requuired optional parameter to my cfc function call for the stored procedure?


      Your help and information is great appreciated,







      <cffunction name="MyFunction" access="remote" returnformat="json">

        <cfargument name ="MyParam1" required="yes">
        <cfargument name ="MaParam2" required="yes">
        <cfargument name ="MyParam3" required="no">

        <cfstoredproc procedure="mySP">
            <cfprocparam value = "#MyParam1#" CFSQLTYPE = "cf_sql_date">
            <cfprocparam value = "#MyParam2#" CFSQLTYPE = "cf_sql_date">
            <cfprocparam value = "#MyParam3#" CFSQLTYPE = "cf_sql_integer">
            <cfprocresult name="sp1" resultset="1">

         <cfreturn #serializeJSON(stcReturn, True)#>


      <a href = "Mycfc.cfc?method=MyFunction&Maparam1=01/01/2007&MyParam2=05/05/2013">My Link</a>

        • 1. Re: optional cfprocparam
          p.sim Level 3

          How did you make the third param in stored proc. optional? Assign a default value? Then, do the same thing.

          Or, you could put an if statement on the third cfprocparam. If the arguments.MyParam3 NEQ a default value, then include the third cfprocparam.


          By the way, <cfargument name ="MyParam3" required="no"> needs a default value. Otherwise, it would throw an error.

          • 2. Re: optional cfprocparam
            iccsi Level 1

            Thanks a milion for the information and help,