我继承了一个在 CF 9.01 上运行的大型应用程序。
我正在将其移植到 Lucee 5.3.3.62,但遇到一些问题
我知道我应该将其替换为 ,但该应用程序有大约 1000 个源文件 (!!),并且由于时间原因,替换所有这些标签目前并不明显。
Lucee 抛出如下错误:
“An object or column name is missing or empty. For SELECT INTO statements, verify each column has a name. For other statements, look for empty alias names. Aliases defined as “” or are not allowed. Change the alias to a valid name.”
起初,我以为日期字段有问题,因为 Lucee 处理它们的方式与 CF 9.01 不同,但事实并非如此。 因此,我创建了一个测试表(在 MS-SQL Server 2008R2 上):
CREATE TABLE [dbo].[LuceeTest01](
[Field1] [nvarchar](50) NULL,
[Field2] [nvarchar](50) NULL ) ON [PRIMARY]
在 Lucee 中,我使用 Microsoft SQL Server(供应商 Microsoft)作为数据源,称为“one”
这是我的测试应用程序:
<cfset Form.Field1 = "Field1">
<cfset Form.Field2 = "Field2">
<cfoutput>
<cfinsert datasource="one"
tablename="LuceeTest01"
formfields="Field1, Field2">
</cfoutput>
当我运行这个时,我得到同样的错误。知道为什么吗? 完整跟踪在这里:https://justpaste.it/6k0hw
谢谢!
编辑1:
好奇的。我尝试使用“jTDS Type 4 JDBC Driver for MS SQL Server and Sybase”作为数据源驱动程序,现在错误是:
The database name component of the object qualifier must be the name of the current database.
这可以追溯到这个声明:
{call []..sp_columns 'LuceeTest01', '', '', 'null', 3}
当我在 Microsoft SQL Server Management Studio 中尝试此操作时,出现相同的错误。 但是,当我指定数据库名称(“one”作为第三个参数)时,MS SQL SMS 中没有错误。
EXEC sp_columns 'LuceeTest01', '', 'one', 'null', 3
Lucee 不应该从数据源配置或其他东西中获取这个参数吗?
编辑2:
正如@Redtopia所建议的,当指定“tableowner”和“tablequalifier”时,它适用于jTDS驱动程序。将使用此作为解决方法。 更新的示例代码:
<cfset Form.Field1 = "Field1">
<cfset Form.Field2 = "Field2">
<cfinsert datasource="onecfc"
tableowner="dbo"
tablename="LuceeTest01"
tablequalifier="one"
formfields="Field1,Field2">
编辑3:
最佳答案
我个人会将 CFINSERT
重构为 queryExecute 并编写一个简单的 InsertInto SQL 语句。我希望我们能够完全删除对 cfinsert
的支持。
关于sql-server - ColdFusion 9.01 -> Lucee 5.3.3.62 和 <cfinsert>/<cfupdate>,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58768532/