I would modify the code to eliminate evaludate

<cfscript>
       function sqlValueFormat(field) {
               if (isNumeric(field)) {
                       field = trim(field);
               } else {
                       field = "'" & trim(field) & "'";
               }
               return field;
       }
</cfscript>
<cfset table_list = "table1, table2, table3, table4, table5, table6">
<cfset k = 1 />
<cfloop index="i" list="#table_list#" delimiters=",">
     <cfquery name="getall" datasource="db_mysql">
             SELECT          *
             FROM            #trim(i)#
     </cfquery>
     <cfloop query="getall">
     <cfquery datasource="db_mssql">
         INSERT INTO #trim(i)#
        <cfloop  list="#getall.columnlist#"  index="j">
            #j# <cfif k LT ListLen( getall.columnlist )>,</cfif>
            <cfset k = k + 1 />
        </cfloop>
        <cfset k = 1 />
        VALUES
        (
            <cfloop  list="#getall.columnlist#"  index="j">
                #sqlValueFormat( getall[j][currentrow] )#
                <cfif k LT ListLen( getall.columnlist )>,</cfif>
                <cfset k = k + 1 />
            </cfloop>
        )
     </cfquery>
     </cfloop>
</cfloop>

On 3/19/07, Mik Muller <[EMAIL PROTECTED]> wrote:
>
> You want to evaluate field to its value
>
> >                if (isNumeric(field)) {
> >                        field = trim(evaluate(field));
> >                } else {
> >                        field = "'" & trim(evaluate(field)) & "'";
> >                }
> >                return field;
>
> Mik
>
>
> At 09:21 AM 3/19/2007, Pete Ruckelshaus wrote:
> >Hi All,
> >
> >I have a data import project that I am trying to simplify, mainly
> >because of the number of tables and amount of data involved.  I'm
> >importing a number of tables from a MySQL database to an MS SQL Server
> >database with an identical structure, except for datatypes being
> >changed where appropriate.
> >
> >The problem is, in my code I am ending up passing in the column name
> >rather than the actual column value.  Can anyone tell me what I'm
> >doing wrong?  Here's my code:
> >
> >
> ><cfscript>
> >        function sqlValueFormat(field) {
> >                if (isNumeric(field)) {
> >                        field = trim(field);
> >                } else {
> >                        field = "'" & trim(field) & "'";
> >                }
> >                return field;
> >        }
> ></cfscript>
> ><cfset table_list = "table1, table2, table3, table4, table5, table6">
> ><cfloop index="I" list="#table_list#" delimiters=",">
> >        <cfquery name="getall" datasource="db_mysql">
> >                SELECT          *
> >                FROM            #trim(i)#
> >        </cfquery>
> >        <cfquery name="insertAll" datasource="db_mssql">
> >                <cfloop query="getall">
> >                        INSERT INTO
> #trim(i)#(#getall.columnlist#)
> >                        VALUES                  (<cfloop
> list="#getall.columnlist#" index="j"
> >delimiters=",">#sqlValueFormat(evaluate(j))#<cfif NOT
> >listLast(getall.columnlist, ",")>,</cfif></cfloop>);
> >                </cfloop>
> >        </cfquery>
> ></cfloop>
> >
> >
> >The error that I'm getting is "cannot convert the value "STAMP" to a
> >boolean" -- "STAMP" is a column name in the table, not the actual
> >chunk of data, which is what I want.
> >
> >Thanks!
> >
> >Pete
> >
> >
>
> 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Create Web Applications With ColdFusion MX7 & Flex 2. 
Build powerful, scalable RIAs. Free Trial
http://www.adobe.com/products/coldfusion/flex2/?sdid=RVJS 

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

Reply via email to