• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

optional cfprocparam

Engaged ,
Aug 08, 2013 Aug 08, 2013

Copy link to clipboard

Copied

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,

Regards,

Iccsi,


<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">
  </cfstoredproc>

  
   <cfreturn #serializeJSON(stcReturn, True)#>

  
  
</cffunction>


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

Views

540

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Engaged , Aug 09, 2013 Aug 09, 2013

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.

Votes

Translate

Translate
Engaged ,
Aug 09, 2013 Aug 09, 2013

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Aug 09, 2013 Aug 09, 2013

Copy link to clipboard

Copied

LATEST

Thanks a milion for the information and help,

Regards,

Iccsi,

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation