On 2/28/07, Deepak Gupta <[EMAIL PROTECTED]> wrote:
> > Hi
> >
> > I am doing this
> > <cfset LocalFilePath="c:/...">
> > <cfquery name="CSVData" datasource="file_csv">
> > SELECT * FROM #LocalFilePath#
> > <cfquery>
> >
> > I have here the query CSVdata, this is basicaly converting CSV to
> > query and now I have to insert this query in the database. I already
> > have a dummy table with these column names in the database.here the
> > column names are dynamic.
> >
> > How i can do that?
> >
> > -DG
>
> I tried using
> <cfloop query="CSVData">
>
>
> <cfquery name="CSVInsert" datasource="">
> Insert into tableName (#ColumnList#)
>                                                                               
>   Values ( ???)
> </cfquery>
> </cfloop>
>
> How can I set values dynamically here from the query loop from above?

Cut and paste a bit of your other code (but don't tell anyone I said to
do that!) with a tweak or two:

<cfloop query="csvdata">

  <cfset rowVals = "">
  <cfloop list="#csvdata.columnlist#" index="colName">
    <cfset rowVals =
listAppend(rowVals,'"#csvdata[colName][csvdata.currentRow]#"')>
  </cfloop>

  <cfquery name="CSVinsert">
    INSERT INTO tableName (#columnList#)
    VALUES (#rowVals#)
  </cfquery>

</cfloop>

untested, but something like that.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
ColdFusion MX7 and Flex 2 
Build sales & marketing dashboard RIA’s for your business. Upgrade now
http://www.adobe.com/products/coldfusion/flex2

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:271076
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4

Reply via email to