我试图通过在select查询中传递员工id来获取所有员工详细信息。不幸的是,我无法获得员工ids的通行证列表。
数组中有员工ids列表
employee_ids=[100,101,200,2003,400]在mule中,我试图使用flowing查询获取所有员工的详细信息。
<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有人能帮我解决这个问题吗?
发布于 2019-11-19 02:58:05
由于数据库连接器使用JDBC实现查询,而JDBC不支持IN子句的参数化,所以它不会这样工作。您可以使用以下MuleSoft KB文章中描述的替代方法https://help.mulesoft.com/s/article/How-to-use-dynamic-IN-clause-in-your-query-statement-using-Database-Connector
https://stackoverflow.com/questions/58924150
复制相似问题