Solved

How to convert dynamically a query row to a list, in Coldfusion

Posted on 2014-10-02
2
545 Views
Last Modified: 2014-10-02
Hi experts,

I have to loop into a query and to output data to a csv file.

My problem is that I want to get the full record (row) and have the different values separate by a semi-colon.
But I can just do something like the following, because there are commas into the data.
<cfset variables.values = replace(variables.getData.currentRow, ",", ";")>

Open in new window


Do you know a trick to achieve this ? Thanks a lot.

Here is the code I’m trying to use :
<cfquery name="variables.getData" datasource="joecool_web">
	select * from jcstktabl where jcid = '#listgetAt('#variables.index#',1, ';')#'
</cfquery>
<!--- build the product’s file --->
<cfif variables.getData.RecordCount NEQ 0>
	<cfset variables.values = replace(variables.getData.currentRow, ",", ";")>
	<cffile action="append" file="#variables.productsFile#" output="#variables.values#" addnewline="true" charset="iso-8859-1">
</cfif>

Open in new window

0
Comment
Question by:adam1h
2 Comments
 
LVL 39

Accepted Solution

by:
gdemaria earned 500 total points
ID: 40357024
Not sure what you're trying to do here, the value of getData.currentRow is a number indicating the record number of the current row; 1,2,3.... etc.

<cfset variables.values = replace(variables.getData.currentRow, ",", ";")>

You may want something like this to create a quoted, comma delimited list..

<cfset variables.values = QuotedValueList(variables.getData)>
0
 

Author Comment

by:adam1h
ID: 40357056
Hi gdemaria,

Indeed, I misunderstood the currentrow function.

Knowing this, coupled with this infos (source), I have correct the statement as follow :
<cfquery name="variables.getData" datasource="joecool_web">
	select * from jcstktabl where jcid = '#listgetAt('#variables.index#',1, ';')#'
</cfquery>
<!--- build the product’s file --->
<cfif variables.getData.RecordCount NEQ 0>
	<cfset variables.values = "">
	<cfloop index="variables.ColumnName" list="#variables.getData.ColumnList#">
		<cfset variables.values &= variables.getData[variables.ColumnName][variables.getData.currentRow]>
	</cfloop>
	<cffile action="append" file="#variables.productsFile#" output="#variables.values#" addnewline="true" charset="iso-8859-1">
</cfif>

Open in new window


I will test it but I think it’s that good way to do it.
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Can I run Access database.exe file thru Coldfusion 2 120
ColdFusion Rereplace 3 78
Coldfusion - query to list question 3 36
popup load of page and setting up of session 8 37
This article  is about submitting  form through  ColdFusion.Ajax.submitForm to the action page and send a response back in JSON format which later can be decoded using ColdFusion.JSON.decode. By this way you can avoid the usual page refresh for subm…
Hi. There are several upload tutorials using jquery and coldfusion. I found a very interesting one here Upload Your Files using Jquery & ColdFusion and Preview them (http://www.randhawaworld.com/) . I did keep the main js functions but made sever…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

770 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