Anyone remember this article?

http://coldfusion.sys-con.com/node/45569

Lets you drop down into Java and pull out the field types that your db
reports back to the JDBC driver.

Its neat on the surface, but too expensive on resources to use on the
fly.  Plus you have to put the for-real username and password directly
into the template... Using vars doesn't work.  Still, I like to use it
during development if I have a monster query that I need to write up.
Saves me the need to look back and forth from screen to screen to
determine what the next cfsqltype is in my query list.

Or stick it in front of a custom tag that writes the sql and
cfqueryparams for you

<!---
<cfmodule
    template="create_record.cfm"
    dbUserName="#attributes.DBUserName#"
    dbPassword="#attributes.DBPassword#"
    DSN="#attributes.DSN#"
    tableName="woof"            
    fieldList="arf,bark,ruff,meow"
    SQLTypeList="CF_SQL_VARCHAR,CF_SQL_VARCHAR,CF_SQL_VARCHAR,CF_SQL_VARCHAR"
    valueList="how,now,brown,cow">
--->
<cfquery
        username="#attributes.DBUserName#"
        password="#attributes.DBPassword#"
        datasource="#attributes.DSN#">
        INSERT INTO #attributes.tableName#
                (
                #attributes.fieldList#
                )
        VALUES
                (
                <cfloop
                        list="#attributes.fieldList#"
                        index="FieldValue">
                        <cfset 
variables.LoopCounter=ListFindNoCase(attributes.fieldList,FieldValue)>
                        <cfqueryparam
                                
cfsqltype="#ListGetAt(attributes.SQLTypeList,variables.LoopCounter)#"
                                
value="#ListGetAt(attributes.valueList,variables.LoopCounter)#"
                                null="#YesNoFormat(not
Len(ListGetAt(attributes.valueList,variables.LoopCounter)))#">
                        <cfif 
compareNoCase(ListLast(attributes.fieldList),FieldValue)>,</cfif>
                </cfloop>
                )
</cfquery>


-- 
-...@robertson--
Janitor, The Robertson Team
mysecretbase.com

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;207172674;29440083;f

Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:321712
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