Solved

How do i pass a named parameter to a UDF?

Posted on 2009-07-09
4
251 Views
Last Modified: 2013-12-24
I have a UDF which I got from cflib.org
http://cflib.org/udf/QueryToCSV2

The UDF = QueryToCSV2(query [, headers] [, cols])

My Question:

How do i pass these params to the UDF

query=MyQuery
headers=FirstName,LastName,Phone
cols=First_Name,Last_name,phonenumber

How would I write the code:
like
#QueryToCSV2(MyQuery,(FirstName,LastName,Phone),(First_Name,Last_name,phonenumber)#

This does not work any ideas?

0
Comment
Question by:LeadCo
  • 2
4 Comments
 
LVL 27

Accepted Solution

by:
azadisaryev earned 500 total points
Comment Utility
just do it like this:

<cfquery name="myQuery" ...>
...
</cfquery>
<cfset headers = "FirstName,LastName,Phone">
<cfset cols = "First_Name,Last_name,phonenumber">
<cfset myCSV = QueryToCSV2(myQuery, headers, cols)>

Azadi
0
 
LVL 59

Expert Comment

by:Kevin Cross
Comment Utility
If I am understanding correctly, you want to pass in a parameter instead of literals for column headings / name you can try like this.

I don't have CF on this machine to test, but can also try EVAL(
<cfset test = QueryToCSV2(MyQuery, FirstName & "," & LastName & "," & Phone, First_Name & "," & Last_name & "," & phonenumber)>
 

<!--- don't believe it is needed on right side of cfset, but can add ## --->

<cfset test = QueryToCSV2(MyQuery, #FirstName# & "," & #LastName# & "," & #Phone#, #First_Name# & "," & #Last_name# & "," & #phonenumber#)>

Open in new window

0
 
LVL 59

Expert Comment

by:Kevin Cross
Comment Utility
Please ignore this part *I don't have CF on this machine to test, but can also try EVAL(
That is what the second was showing using the #variablename# as I read your question to mean that FirstName was a named parameter, etc.
0
 

Author Closing Comment

by:LeadCo
Comment Utility
Thanks!
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Periodically we have to update or add SSL certificates for customers. Depending upon your hosting plan you may be responsible for the installation and/or key generation. In the wake of Heartbleed many sites were forced to re-key. We will concen…
This article describes how to use the timestamp of existing data in a database to allow Tableau to calculate the prior work day instead of relying on case statements or if statements to calculate the days of the week.
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now