Created
May 25, 2023 21:06
-
-
Save jonbartels/37f4d05cf077ee8802f7b9e15200db81 to your computer and use it in GitHub Desktop.
Query Mirth Connect event table by event name and pick out channel name and channel ID from the attributes. Postgres 13 and newer
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
WITH attribute_rows AS (select e.name, | |
e.date_created, | |
xml_element.* | |
from "event" e, | |
xmltable('//linked-hash-map/entry' | |
passing (e."attributes"::xml) | |
columns "key" text PATH 'string[1]', | |
"value" text PATH 'string[2]' | |
) as xml_element | |
where e.name like '%Deploy%' | |
or e.name like '%Redeploy%') | |
SELECT name as event_name, | |
date_created, | |
unnest(REGEXP_MATCHES(value, 'Channel\[id=(.*),name.*' )) as channel_id, | |
unnest(REGEXP_MATCHES(value, 'Channel\[id=.*,name=(.*)\]' )) as channel_name | |
FROM attribute_rows | |
WHERE "key" = 'channel' ; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment