>Yes, I can convert it into a cfquery object, and a lot of the time I will,
>but I also want to be able to insert the data into another table in another
>db which I can do directly rather than converting it to a query first.
>
>Hence the reason to split it into separate methods.
Personally I would always convert it to a query. However, it may be a moot
point because I do not think you can iterate through a resultset after it is
closed.
>I'm not very clear on this var thing in as much as
><cfset Class.forName("sun.jdbc.odbc.JdbcOdbcDriver")>
>works, but
><cfset var Class.forName("sun.jdbc.odbc.JdbcOdbcDriver")>
>throws the error: You cannot use a variable reference with "." operators in
>this context
VAR declarations must be at the top of the function, just after the
cfarguments. So declare all of your variables at the top, then use them as
normal inside the function. ie without the VAR keyword.
<cffunction ...>
<cfargument ...>
<cfset var Class = "">
<cfset var DriverManager = "">
...
<cfset Class = createObject("java", "java.lang.Class")>
<cfset Class.forName("sun.jdbc.odbc.JdbcOdbcDriver")>
<cfset DriverManager = createObject("java", "java.sql.DriverManager")>
...
</cffunction>
Another option is to use a single structure to store all of your function local
variables.
<cffunction ...>
<cfargument ...>
<!--- create structure for storing all local variables --->
<cfset var Local = {}>
<!--- place all variables in the "Local" structure --->
<cfset Local.Class = createObject("java", "java.lang.Class")>
<cfset Local.Class.forName("xxxx.xxxx.xxxxx")>
<cfset Local.DriverManager = createObject("java", "java.sql.DriverManager")>
...
</cffunction>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to
date
Get the Free Trial
http://ad.doubleclick.net/clk;192386516;25150098;k
Archive:
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:304537
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4