Postgresql 如何使用NamedParameterJDBCTemplate将数组参数传递给将数组[';EGY';,';IND';]作为参数的函数?
我的功能是Postgresql 如何使用NamedParameterJDBCTemplate将数组参数传递给将数组[';EGY';,';IND';]作为参数的函数?,postgresql,Postgresql,我的功能是f_wfc_transaction_summary_isocc_ft_sum_no_tid('2015-07-01 14:00:00'、'2015-07-21 01:00:00'、数组['EGY'、'IND']、'LINK') wfc_导致('TM_OK'、'TM_NO_CHANGE') 我正在使用NamedParameterJdbcTemplate: MapSqlParameterSource params = new MapSqlParameterSource();
f_wfc_transaction_summary_isocc_ft_sum_no_tid('2015-07-01 14:00:00'、'2015-07-21 01:00:00'、数组['EGY'、'IND']、'LINK')
wfc_导致('TM_OK'、'TM_NO_CHANGE')
我正在使用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数组类型。找到了解决方案:
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);