【问题标题】:Mule Soft Database Select Query with In Where Condition带有 In Where 条件的 Mulesoft 数据库选择查询
【发布时间】:2019-11-18 22:56:53
【问题描述】:

我正在尝试通过在选择查询中传递员工 ID 来提供所有员工详细信息。不幸的是,我无法获得员工 ID 的通过列表。

我在数组中有员工 ID 列表

employee_ids=[100,101,200,2003,400]

在 mule 中,我尝试使用流动查询获取所有员工详细信息

<db:select config-ref="mysql_Configuration" doc:name="get Employee details">
            <db:sql>
                select * from employee where employee_id in (:EMP_IDS)
            </db:sql>
            <db:input-parameters>
               #[{'EMP_IDS' : vars.listEmployeeIds}]
            </db:input-parameters>          

        </db:select>

它抛出一个错误:

********************************************************************************
Message               : Invalid column type.
Error type            : DB:QUERY_EXECUTION

我也尝试使用逗号分隔值传递所有员工 ID

哪里的值

listEmployeeIds =[100,101,200,2003,400] joinBy "," 

结果 = "100,101,200,2003,400"

<db:select config-ref="mysql_Configuration" doc:name="get Employee details">
                <db:sql>
                    select * from employee where employee_id in (:EMP_IDS)
                </db:sql>
                <db:input-parameters>
                   #[{'EMP_IDS' : vars.listEmployeeIds}]
                </db:input-parameters>          

            </db:select>

但这也给了我错误 由于间接地将其转换为字符串,因此它给了我:

Message               : java.sql.SQLSyntaxErrorException: invalid number
.
Error type            : DB:BAD_SQL_SYNTAX

谁能帮我解决这个问题?

【问题讨论】:

    标签: sql database select mule mule4


    【解决方案1】:

    因为数据库连接器使用 JDBC 来实现查询,并且 JDBC 不支持 IN 子句的参数化,所以它不会那样工作。您可以使用以下 MuleSoft 知识库文章 https://help.mulesoft.com/s/article/How-to-use-dynamic-IN-clause-in-your-query-statement-using-Database-Connector

    中描述的替代方法

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-06-30
      • 2018-07-02
      • 2016-01-23
      • 2014-12-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-05-02
      相关资源
      最近更新 更多