|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stay one step ahead of the competition. Evaluate and give feedback
on some of the hottest web development tools on the market today.
Make your opinion heard! Click
Here
|
|
#1
|
|||
|
|||
|
Can you exprot database records with ColdFusion?
Hi,
I'm a beginner with using ColdFusion. I interact with some Oracle tables within my ColdFusion templates and. I need to export the entire contents of AN Oracle table into a text or excel file (or any other format). Is there a way to achieve this in ColdFusion? Thanks. |
|
#2
|
|||
|
|||
|
You could do this by using a select * from myTable in a cfquery block to get a query containing all the records from that table. Then you could manually loop over the query and write each line to a text file. Or you could use cfwddx to translate the entire result set to XML and write that to a file...there are many options. But the bottom line is yes, this can be done easily.
|
|
#3
|
|||
|
|||
|
Thanks for replying, kiteless.
I don't know XML yet, as far as your second solution. I've thought of doing this by using your first solution. I thought there might be a built-in feature in CF that does this in an easier way. Can you show me the syntax as to how I can write retrieved records into .txt file pelase? regards spartik |
|
#4
|
|||
|
|||
|
Something like this, depending on your needs:
Code:
<cfquery name="myQuery" datasource="myDSN"> select firstName, lastName from myTable </cfquery> <cffile action="WRITE" file="#getDirectoryFromPath( getTemplatePath() )#/myexportfile.txt" output=""> <cfoutput query="myQuery"> <cffile action="APPEND" file="#getDirectoryFromPath( getTemplatePath() )#/myexportfile.txt" output="#myQuery.firstName# #myQuery.lastName#" addnewline="Yes"> </cfoutput> |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ColdFusion Development > Can you exprot database records with ColdFusion? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|