Solved

How do i pass a named parameter to a UDF?

Posted on 2009-07-09
4
252 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
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 59

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 59

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

Give your grad a cloud of their own!

With up to 8TB of storage, give your favorite graduate their own personal cloud to centralize all their photos, videos and music in one safe place. They can save, sync and share all their stuff, and automatic photo backup helps free up space on their smartphone and tablet.

Question has a verified solution.

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

Sometimes databases have MILLIONS of records and we need a way to quickly query that table to return the results me need. Sure you could use CFQUERY but it takes too long when there are millions of records. That is why SOLR was invented. Please …
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 …
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

911 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

20 Experts available now in Live!

Get 1:1 Help Now