At 06:32 AM 1/16/01 -0800, you wrote:
>Can anyone give me an example on how to copy a table from one ODBC data
>source to another remotely using Cold Fusion calls?
Simple.
<cfquery name="original" datasource="somedatasource">
select * from originaltable
</cfquery>
<cfloop query="original">
<cfquery datasource="someotherdatasource">
insert into copytable
(field1, field2, field3,...) values
(#field1#, #field2#, #field3#,...)
</cfquery>
</cfloop>
This can be sort of processing intensive if the original table is large, so
if it is, you might want to do the loop this way instead.
<cfloop index="i" from="1" to="500">
<cfquery datasource="someotherdatasource">
insert into copytable
(field1, field2, field3,...) values
(#original.field1[i]#, #original.field2[i]#,
#original.field3[i]#,...)
</cfquery>
</cfloop>
Then you can change the from and to numbers and do it in batches. Just
remember that if you end one batch at 500, start the next one at 501
instead of 500. I'm always paranoid I'm gonna screw that up and start with
the last index.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at
http://www.fusionauthority.com/bkinfo.cfm
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists