Question
<CFFUNCTION> ans <CFRETURN>
Within my cfloop I have cfswitch cfcase statement and within
each cfcase I need to do some SQL insert and update. Instead of
writing cfquery within every cfcase I'm thinking of writing a
function call, passing 2 parameters needed for the insert and
update done inside my function.
I don't know how to call a function that does not a return a value and in CFFUNCTION I need to have CFRETURN but I don't need to return any value.Is there anyway to do this?
<CFLOOP query name="My Query" datasource="myDSN">
<CFSWITCH expression="#LCode#">
<CFCASE value="A">
Instead of writing cfqueries for insert and update for each CFCASE, I'm thinking of
writing a function call. I don't need a return value from the CFFunction
<cfoutput>myFunction( parameter1, parameter2)</cfoutput>
</CFCASE>
<CFCASE value="B">
<cfoutput>myFunction( parameter1, parameter2)</cfoutput>
</CFCASE>
<CFCASE value="C">
<cfoutput>myFunction( parameter1, parameter2)</cfoutput>
</CFCASE>
<CFCASE value="D">
<cfoutput>myFunction( parameter1, parameter2)</cfoutput>
</CFCASE>
<CFCASE value="E">
<cfoutput>myFunction( parameter1, parameter2)</cfoutput>
</CFCASE>
</CFSWITCH>
</CFLOOP>
<CFFUNCTION name="myFunction>
<cfargument name="param1" type="numeric" required="true">
<cfargument name="param2" type="string" required="true">
<!--- cfquery for my sql statemtent in here --->
<cfquery name="NeedInsert" datasource="MyDB>
Insert Into myTable (column1,2,3)
Values (#Value1#, #Value2#, #Value3#
</cfquery>
<cfquery name="NeedUpdate" datasource="MyDB>
Update myOtherTable SET Columni=#Value1#
</cfquery>
</CFFUNCTION>
I don't know how to call a function that does not a return a value and in CFFUNCTION I need to have CFRETURN but I don't need to return any value.Is there anyway to do this?
<CFLOOP query name="My Query" datasource="myDSN">
<CFSWITCH expression="#LCode#">
<CFCASE value="A">
Instead of writing cfqueries for insert and update for each CFCASE, I'm thinking of
writing a function call. I don't need a return value from the CFFunction
<cfoutput>myFunction( parameter1, parameter2)</cfoutput>
</CFCASE>
<CFCASE value="B">
<cfoutput>myFunction( parameter1, parameter2)</cfoutput>
</CFCASE>
<CFCASE value="C">
<cfoutput>myFunction( parameter1, parameter2)</cfoutput>
</CFCASE>
<CFCASE value="D">
<cfoutput>myFunction( parameter1, parameter2)</cfoutput>
</CFCASE>
<CFCASE value="E">
<cfoutput>myFunction( parameter1, parameter2)</cfoutput>
</CFCASE>
</CFSWITCH>
</CFLOOP>
<CFFUNCTION name="myFunction>
<cfargument name="param1" type="numeric" required="true">
<cfargument name="param2" type="string" required="true">
<!--- cfquery for my sql statemtent in here --->
<cfquery name="NeedInsert" datasource="MyDB>
Insert Into myTable (column1,2,3)
Values (#Value1#, #Value2#, #Value3#
</cfquery>
<cfquery name="NeedUpdate" datasource="MyDB>
Update myOtherTable SET Columni=#Value1#
</cfquery>
</CFFUNCTION>
