使用传入的webhook将SQL消息发送到Slack频道
问题描述:
我想使用Slack传入的webhooks和Invantive SQL将基于Exact Online查询的消息发送到Slack频道。使用传入的webhook将SQL消息发送到Slack频道
如何在没有大量SQL函数的情况下正确转义JSON?
答
一些尝试后,我发现这是做工精细:
select to_char
(httppost
('https://hooks.slack.com/services/XXX/YYY/zzzzzzzzz'
, 'application/json'
, to_binary
('{'
|| jsonencode('channel')
|| ': '
|| jsonencode('#test')
|| ', '
|| jsonencode('username')
|| ': '
|| jsonencode('testuser')
|| ', '
|| jsonencode('text')
|| ': '
|| jsonencode('Companies in city of ' || act.city || ': ' || act.companynames)
|| '}'
)
)
)
from (select act.city
, listagg(act.name) companynames
from exactonlinerest..accounts act
where act.city in ('Haelen', 'Horn', 'Heythuysen')
group
by act.city
)
的HTTP POST是不是在这个意义上,它有一个副作用非常优雅,但它的工作。