Skip to main content

Query templates

What are Query templates and how to use them

Updated over a year ago

No one likes to do work that can be easily automated. That's why we made Query templates to save you a lot of time and effort - it is a place you can store your jurisdictions risk ratings, industries or any other data you'd wish to use when you write your Scenarios, Risk Rules or Clearance rules.

💡An example.

Your list of high-risk countries as listed in the screenshot below are Afghanistan, Iraq, Myanmar, North Korea, Sudan, Syria, Uganda, and Yemen.

But, in 6 months, the world situation has changed and North Korea is no longer considered high-risk, but Hong Kong has suddenly been added to that list.

Rather than going through each and every one of your scenarios and risk rules — deleting North Korea and adding Hong Kong — you could just use query templates — and use the name in place of writing out every one of those countries.


Query template in use example

Below is an example scenario that generates an alert when young customer has a high value transaction with sender or receiver from a high risk country (and the query template name is iso2_high_risk_country).


Query Template Guidelines

Query templates with values separated by commas are case sensitive and should be used when an exact match is needed, e.g. high risk country lists. For example,

select new.attributes->>'sender_country' in ($high_risk_countries) 
from transaction new
where new.id = $transactionId

where the query template high_risk_countries contains IR, SY, NK, ...The sender country needs to match exactly an entry in the query template.

The ones separated by | are for pattern matching and are used most often for detecting red flag words in the transaction reference field. They are not case sensitive and allows regular expressions to be used. For example,

select new.reference ~* ($red_flag_words) 
from transaction new
where new.id = $transactionId

where the query template red_flag_words is drug|gun|bomb|...The reference can be longer than the entry in the query template, e.g. "Money for making bombs", but it would still match because "bomb" is present in the reference text.


How to edit or delete a query template

You can find query templates in the Analyst Toolbox.

If you have the permissions to edit queries, then you should see an Edit button on the far right of each query.

From there, a pop-up box opens. There, you add or delete whichever part of that category has changed (i.e. remove 'KP' and add 'HK') and click Save. Or, if you want to delete it, pick the Delete button.

From then on, everything will be updated in all scenarios or risk rules that use that query template name you just edited.

❗ You won’t be able to change Query template’s name or delete a Query template if it is used in a Scenario, Risk rule or Clearance rule.

Did this answer your question?