如何使用NamedParameterJDBCTemplate将数组参数传递给以array ['EGY','IND']作为参数的函数? [英] How to pass an array parameter using NamedParameterJDBCTemplate to a function who takes array['EGY','IND'] as paramters?
本文介绍了如何使用NamedParameterJDBCTemplate将数组参数传递给以array ['EGY','IND']作为参数的函数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的函数是 f_wfc_transaction_summary_isocc_ft_sum_no_tid('2015-07-01 14:00:00','2015-07-21 01:00:00',array ['EGY','IND'] ,'LINK')
其中wfc_result('TM_OK','TM_NO_CHANGE')
我正在使用NamedParameterJdbcTemplate:
I am using NamedParameterJdbcTemplate:
MapSqlParameterSource params = new MapSqlParameterSource();
params.addValue("isoCountryCode", isoCountryCode ,java.sql.Types.ARRAY ); --> this is the array['EGY','IND']
result = template.queryForList(overallDataQuery,params);
我尝试了几种方法:
1. isoCountryCode字段作为数组
2 。isoCountryCode字段,其格式为- {'EGY','IND'}
不断出现postgres错误-无法将字符串转换为postgres数组类型。
However, I keep getting postgres errors - String cannot be converted to postgres array type.
推荐答案
找到了解决方案:
MapSqlParameterSource params = new MapSqlParameterSource();
params.addValue("featureType", featureType);
params.addValue("fromDate", fromDate);
params.addValue("toDate", toDate);
Array array = null;
try {
Connection con = dataSource.getConnection();
array = con.createArrayOf("text", isoCountryCode);
}
catch (SQLException e) {}
params.addValue("isoCountryCode", array);
这篇关于如何使用NamedParameterJDBCTemplate将数组参数传递给以array ['EGY','IND']作为参数的函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文