@Bean
OracleAqQueueFactoryBean etlQueueFactory() throws JMSException, SQLException {
final OracleAqQueueFactoryBean bean = new OracleAqQueueFactoryBean();
bean.setConnectionFactory(jmsQueueConnectionFactory());
bean.setOracleQueueUser("USER");
bean.setOracleQueueName("QUEUE");
return bean;
}
@Bean
DefaultMessageListenerContainer jmsContainer() throws JMSException, SQLException {
final DefaultMessageListenerContainer bean = new DefaultMessageListenerContainer();
bean.setConnectionFactory(jmsQueueConnectionFactory());
bean.setDestination(etlQueueFactory().getObject());
bean.setMessageListener(new MyListener());
bean.setSessionTransacted(false);
return bean;
}
public class MyListener implements MessageListener {
@Override
public void onMessage(Message message) {
...
}
}
我无法将我的函数参数插入到这样的查询中。
答案 0 :(得分:2)
在你的陈述中,甚至引号都不匹配......
此外,它容易受到SQL injection的攻击。</ p>
尝试这样的事情:
CREATE OR REPLACE FUNCTION dynamicJsonValue(varchar(64)) RETURNS void AS
$$UPDATE "table" SET "field" = 'value'
WHERE "json_field"
@> CAST ('{"key": "' || replace($1, '"', '') || '" }' AS jsonb)$$
LANGUAGE sql STRICT;
答案 1 :(得分:2)
想出来:
CREATE OR REPLACE FUNCTION dynamicJsonValue(varchar(64)) RETURNS VOID AS
'UPDATE "table" SET "field" = ''value''
WHERE "json_field" @> jsonb_build_object(''field'', $1);'
LANGUAGE SQL VOLATILE;