sql - How can I call a function in another CFC file from within a query of a function in one cfc file? -


i have 1 cfc file (info.cfc) multiple functions shown below.

<cfcomponent output="true" extends="datefunctions">     <cffunction name="getstatuses" access="remote" returntype="any" output="true" returnformat="plain">        ...     </cffunction>      <cffunction name="viewdate" access="remote" returntype="any" output="true" returnformat="plain">         <cfquery  name="records">               select                  dbo.tickets.incident,                  dbo.tickets.start_date,                  dbo.tickets.days_due                                dbo.tickets             </cfquery>     </cffunction> </component> 

and other cfc file (datefunctions.cfc) containing function 2 arguments , returning date. datefunctions.cfc file follows:

<cfcomponent output="true" name="datefunctions"">     <cffunction name="addbusinessdays" access="remote" returntype="any" output="true" returnformat="plain">        <cfargument name="daystoadd"                  required="yes"                  type="numeric"                  hint="the number of whole business days add or subtract given date">         <cfargument name="date"                  required="no"                  type="date"                  hint="the date object start counting from.."                  default="#nowdatetime#">           ...          ... <!--- perform tasks --->           <cfreturn date>     </cffunction> </cfcomponent> 

question: how can invoke "addbusinessdays" within query in (info.cfc) producing column of results.

i thought might have been able like:

<cffunction name="viewdate" access="remote" returntype="any" output="true" returnformat="plain">     <cfquery  name="records">           select              dbo.tickets.incident,              dbo.tickets.start_date,              dbo.tickets.days_due,              (                <cfinvoke component="datefunctions" method="addbusinessdays" returnvariable="date">                   <cfinvokeargument name="daystoadd" value="#dbo.tickets.days_due#">                   <cfinvokeargument name="date" value="#dbo.tickets.start_date#">                </cfinvoke>              ) due_date                        dbo.tickets         </cfquery> </cffunction> 

you following caveat of there additional processing loop.

edit: per discussion below, updated cfoutput cfloop

 <cffunction name="viewdate" access="remote" returntype="any" output="true" returnformat="plain">     <cfquery  name="records">           select              dbo.tickets.incident,              dbo.tickets.start_date,              dbo.tickets.days_due,              '' due_date                        dbo.tickets         </cfquery>      <cfset df = createobject("component","datefunctions")>      <cfloop query="records">         <cfset records.due_date = df.addbusinessdays(days_due, start_date)>     </cfloop>     <cfreturn records> </cffunction> 

Comments

Popular posts from this blog

wordpress - (T_ENDFOREACH) php error -

Export Excel workseet into txt file using vba - (text and numbers with formulas) -

Using django-mptt to get only the categories that have items -