Solved

How do i pass a named parameter to a UDF?

Posted on 2009-07-09
4
256 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 27

Accepted Solution

by:
azadisaryev earned 500 total points
ID: 24818272
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 60

Expert Comment

by:Kevin Cross
ID: 24818340
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 60

Expert Comment

by:Kevin Cross
ID: 24818357
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
ID: 31601803
Thanks!
0

Featured Post

Don't Miss ATEN at InfoComm 2017!

Visit booth #2167 to see the  new ATEN VM3200 32 x 32 Modular Matrix Switch. Other highlights include the VE8950 4K HDMI Over IP Extender, VS1912 12-Port DP Video Wall Media Player  and VK2100 ATEN Control System. Register now with Free Pass Code ATEN288!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Confronted with some SQL you don't know can be a daunting task. It can be even more daunting if that SQL carries some of the old secret codes used in the Ye Olde query syntax, such as: (+)     as used in Oracle;     *=     =*    as used in Sybase …
This post looks at MongoDB and MySQL, and covers high-level MongoDB strengths, weaknesses, features, and uses from the perspective of an SQL user.
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL (https://www.percona.com/software/mysql-database/percona-server) and MongoDB (https://www.percona.com/software/mongo-…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…

688 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