sql-server - ColdFusion 9.01 -> Lucee 5.3.3.62 和 <cfinsert>/<cfupdate>

标签 sql-server coldfusion cfml lucee

我继承了一个在 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:

此处提交的错误:https://luceeserver.atlassian.net/browse/LDEV-2566

最佳答案

我个人会将 CFINSERT 重构为 queryExecute 并编写一个简单的 InsertInto SQL 语句。我希望我们能够完全删除对 cfinsert 的支持。

关于sql-server - ColdFusion 9.01 -> Lucee 5.3.3.62 和 <cfinsert>/<cfupdate>,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58768532/

相关文章:

SQL Server 2005 如何在没有游标的情况下迭代 CSV 或表?

sql - 为什么 CREATE PROCEDURE 命令中允许使用 DEFAULT 关键字

sql - 在 SQL Server 2012 中,如何从 View 、函数或存储过程中获取列名和数据类型?

xml - 如何在 Coldfusion 中将数组添加到 XML 对象?

javascript - 突出显示搜索结果字符串大小写问题

sql-server - SQL Server 使用 Group by 和 union 选择查询

pdf - 如何将 ColdFusion 页面转换为 PDF 下载?

unit-testing - 创建一个 cffile action=upload 将处理的模拟请求

cfscript 标记输出中的 xml 注释

security - ColdFusion 安全