Tuesday, March 23, 2010

Insert Query resultset to database table

I need to insert a query object that originated as a CSV file
ito a database table.



I am trying the following where tmp_batch_load is a database
table and sourceRS is the query object from the CSV file. CF does
not recognize that sourceRS is not a data base table



%26lt;cfquery name=test datasource=datasource%26gt;

insert into tmp_batch_load
(transaction_Identifier,transaction_content)

select transaction_identifier,transaction content from
sourceRs

%26lt;/cfquery%26gt;



Thanks

TimInsert Query resultset to database table
You can't reference a query object in the FROM clause when
using ''datasource'' because your database doesn't know anything
about in memory CF query objects.



You could use your db's tools to insert the CSV file
directly. For example, ms sql has BULK INSERT , etc. . Another
option is to loop through the query an insert one row of data at a
time. The first option is usually more efficient.

No comments:

Post a Comment