0

我试图通过在选择查询中传递员工 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

谁能帮我解决这个问题?

4

1 回答 1

1

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

于 2019-11-19T02:58:05.083 回答