Paul,
I ran into this same issue the other day. It seems that ColdFusion is
adding line breaks before the value returned by your function, which
generates an error on your DB. So calling the function from within
<cfquery> would result in the following SQL being sent to the DB.
INSERT INTO myTable(some_field)
VALUES('
value_returned_by_function_directly')
But setting a variable to the value returned by the function (which is
the way that I had to setup my query) would send this.
INSERT INTO myTable(some_field)
VALUES('value_returned_by_variable_calling_function')
Not sure why. Has anyone else come across this?
Robert
-----Original Message-----
From: Paul [mailto:[EMAIL PROTECTED]
Sent: Thursday, April 20, 2006 4:24 PM
To: CF-Talk
Subject: cfc/sql strange behavior
I'm essentially creating a glorified import process to join data from
two of
our systems and I'm seeing some strange things from CF/SQL Server 2000.
It's fairly simple - I'm looping over one query and inserting data into
a
second database, calling private functions within the same CFC to
retrieve
some of the values.
Here is the code that results in "invalid object" database error:
<cfoutput query="q">
<cfquery name="qq" datasource="mas500_orders">
INSERT INTO tecSOLine(ItemKey)
VALUES(<cfqueryparam value="#getItemKey(sku)#"
cfsqltype="cf_sql_integer">)
</cfquery>
</cfoutput>
I get the same error when I try #getItemKey(sku)# without the
cfqueryparam.
The following code, wherein I retrieve the key ahead of the insert query
and
then use cfqueryparam, does NOT produce the error.
<cfoutput query="q">
<cfset myKey=getItemKey(sku)>
<cfquery name="qq" datasource="mas500_orders">
INSERT INTO tecSOLine(ItemKey)
VALUES(<cfqueryparam value="#myKey#"
cfsqltype="cf_sql_integer">)
</cfquery>
</cfoutput>
I'm stumped. Any clues?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Message: http://www.houseoffusion.com/lists.cfm/link=i:4:238339
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe:
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54